如何使用字符串(查询mySQL)进行Image.source更改

时间:2019-06-13 07:22:57

标签: c# wpf

我喜欢将Image.Source更改为string

图像源中需要更改的名称(id)来自数据库。在代码中,这将导致包含实际名称的字符串,因此Visual Studio将不接受该名称。

错误是:

  

错误CS1061'字符串'不包含'源'的定义,并且找不到可以接受的扩展方法'源'接受类型为'字符串'的第一个参数(您是否缺少using指令或程序集引用?)

我该如何解决此问题,或者有人知道该怎么做?

private void BtnStart_Click_Drive(object sender, RoutedEventArgs e)
{
    //Connect to database
    DBConnect MyConnection = new DBConnect();
    //Create query
    //string query = "SELECT * FROM modality where TestType IN ('ping','port','service') AND Mute = false";
    string query = "SELECT * FROM modality where RecordStatus > 0";
    //Get Modalitylist
    List<Modality> MyList = MyConnection.GetModalities(query);


    foreach (Modality Mod in MyList)
    {
        //Debug.WriteLine(Mod.HostName + "  " + Mod.Description + " " + Mod.TestType);
        string host = Mod.HostName + "";
        string id = Mod.Id + "";
        string port = Mod.Port + "";
        string svcName = Mod.ServiceName + "";
        string HostAE = Mod.AEHostName + "";
        string ClientAE = Mod.AEClientName + "";
        string Mute = Mod.Mute + "";
        string RecordStatus = Mod.RecordStatus + "";
        string Check = "a" + id;
        string LastCheckDescr = Mod.LastCheckDescr + "";



        id.Source = new BitmapImage(new Uri(@"C:\Users\vriesee\source\repos\KMS2\KMS2\ECG Bad.png"));

        ListBox.Items.Add(Check + "  " + LastCheckDescr);


        if (LastCheckDescr.Contains("Ok") == true)
        {



        }
        else
        {

        }
    }

}

0 个答案:

没有答案