我试图制作一个代码,将我所有的数据从网格插入到表格中。在网格中我显示我需要的东西,这不是问题,或者它没有给出错误
显示此错误:
System.Data.SqlClient.SqlException:“{”附近的语法不正确
string StrQuery;
try
{
using (SqlConnection conn = new SqlConnection(stringcon))
{
using (SqlCommand comm = new SqlCommand())
{
comm.Connection = conn;
conn.Open();
for (int i = 1; i < bunifuCustomDataGrid2.Rows.Count; i++)
{
StrQuery = @"INSERT INTO concediati VALUES ("
+ bunifuCustomDataGrid2.Rows[i].Cells["firstname"].ToString() + ", "
+ bunifuCustomDataGrid2.Rows[i].Cells["lastname"].ToString() + ", "
+ bunifuCustomDataGrid2.Rows[i].Cells["CARS"].ToString() + ", "
+ bunifuCustomDataGrid2.Rows[i].Cells["RENT"].ToString() + ", "
+ bunifuCustomDataGrid2.Rows[i].Cells["CLIENT"].ToString() + ");";
comm.CommandText = StrQuery;
comm.ExecuteNonQuery();
}
}
}
}
catch (Exception)
{
throw;
}
更新了参数。
string StrQuery;
try
{
using (SqlConnection conn = new SqlConnection(stringcon))
{
using (SqlCommand comm = new SqlCommand())
{
comm.Connection = conn;
conn.Open();
}
}
}
}
现在它给出了一个不同的错误:
System.FormatException:“输入字符串的格式不正确。”
图片: capture1
capture25
capture25
capture25
capture5
HUH函数
江户川乱折腾
千万里不及你
相关分类