字符串转换的问题?
要实现查询表中的某一字段的数字插入到 textBoxbrno 中,代码如下:
private void Form1_Load(object sender, EventArgs e)
{
try
{
string strsqlconn = "server= (local);database = AIS20090413161510;trusted_connection = yes";
SqlConnection conn = new SqlConnection(strsqlconn);
string str = "Select famount from t_voucherentry where fvoucherid = 185 and fentryid =0 ";
conn.Open();
int a;
a = Int32.Parse(str);
textBoxbrno.Text = a.ToString();
SqlCommand cmd = new SqlCommand(str, conn);
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("over");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
报错:输入字符串的格式不正确。何解?