我试图使用以下代码将我的手机连接到PC数据库:
string cString = @"Persist Security Info=False;Integrated Security=false;Initial Catalog=myDB;server=192.168.1.11,1433SqlExpress";
SqlConnection connection = new SqlConnection(cString);
connection.Open();
using (SqlCommand cmd = new SqlCommand("SELECT name1 FROM Product", connection))
{
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
t.Text += rdr.GetString(rdr.GetOrdinal("name1")) + System.Environment.NewLine;
}
}
}
不幸的是,我收到错误:"输入字符串不是相应的格式",来源:mscorlib。
我知道连接字符串中存在错误(连接后抛出异常。打开())
有什么想法吗?提前感谢!
您当前的文化格式不正确
protected override void OnResume()
{
base.OnResume();
//Here you would read it from where ever.
var userSelectedCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = userSelectedCulture;
}