Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SQL CE插入错误_C#_Sql_Mobile - Fatal编程技术网

C# SQL CE插入错误

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

我正在为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.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