C# SQL CE插入错误
我正在为PDA(WM 6)创建一个应用程序。C# SQL CE插入错误,c#,sql,mobile,C#,Sql,Mobile,我正在为PDA(WM 6)创建一个应用程序。 当我尝试在数据库中插入数据时,总是会遇到此错误 错误: public static bool InsertPedido(int id, int Vim, DateTime date, int quantidade) { SqlCeConnection conn = new SqlCeConnection("Data Source=" + System.IO.Path.GetDirectoryName(System.Reflection.Ass
当我尝试在数据库中插入数据时,总是会遇到此错误 错误:
public static bool InsertPedido(int id, int Vim, DateTime date, int quantidade)
{
SqlCeConnection conn = new SqlCeConnection("Data Source=" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\\DataPedido.sdf; Password =SUPER2000PED;");
conn.Open();
try
{
SqlCeCommand comando = new SqlCeCommand(@"INSERT INTO Pedido([IDLayout], [Vim], [Data], [Quantidade])VALUES(@IDLayout,@Vim,@Data,@Quantidade))", conn);
comando.Parameters.AddWithValue("@IDLatout", SqlDbType.Int).Value = id;
comando.Parameters.AddWithValue("@Vim", SqlDbType.Int).Value = Vim;
comando.Parameters.AddWithValue("@Data", SqlDbType.DateTime).Value = date;
comando.Parameters.AddWithValue("@Quantidade", SqlDbType.Int).Value = quantidade;
int row = comando.ExecuteNonQuery();
return true;
}
catch
{
throw;
}
finally
{
conn.Close();
}
}
分析查询时出错。[令牌行编号=1,令牌行偏移量=100,令牌出错=)]
代码:
public static bool InsertPedido(int id, int Vim, DateTime date, int quantidade)
{
SqlCeConnection conn = new SqlCeConnection("Data Source=" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\\DataPedido.sdf; Password =SUPER2000PED;");
conn.Open();
try
{
SqlCeCommand comando = new SqlCeCommand(@"INSERT INTO Pedido([IDLayout], [Vim], [Data], [Quantidade])VALUES(@IDLayout,@Vim,@Data,@Quantidade))", conn);
comando.Parameters.AddWithValue("@IDLatout", SqlDbType.Int).Value = id;
comando.Parameters.AddWithValue("@Vim", SqlDbType.Int).Value = Vim;
comando.Parameters.AddWithValue("@Data", SqlDbType.DateTime).Value = date;
comando.Parameters.AddWithValue("@Quantidade", SqlDbType.Int).Value = quantidade;
int row = comando.ExecuteNonQuery();
return true;
}
catch
{
throw;
}
finally
{
conn.Close();
}
}
结束括号太多
SqlCeCommand comando = new SqlCeCommand(@"INSERT INTO Pedido
([IDLayout], [Vim], [Data], [Quantidade])
VALUES(@IDLayout,@Vim,@Data,@Quantidade)", conn);
^^^
西方最快的枪<代码>+1