請幫助我,我不知道有什麼可以是錯誤的下面的代碼:ASP.NET ODBC查詢與參數
OdbcConnection conn = new OdbcConnection(connString);
String query = "INSERT INTO customer (custId, custName, custPass, "+
"custEmail, custAddress, custAge) VALUES (" +
"@ID, @Name, @Pass, @Email, @Address, @Age)";
OdbcCommand exe = new OdbcCommand(query, conn);
exe.Parameters.Add("@ID", OdbcType.UniqueIdentifier).Value = id;
exe.Parameters.Add("@Name", OdbcType.VarChar).Value = name;
exe.Parameters.Add("@Pass", OdbcType.VarChar).Value = pass;
exe.Parameters.Add("@Email", OdbcType.VarChar).Value = email;
exe.Parameters.Add("@Address", OdbcType.VarChar).Value = address;
exe.Parameters.Add("@Age", OdbcType.Int).Value = age;
conn.Open();
exe.ExecuteNonQuery(); // ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 6.
此代碼拋出我Too few parameters.
錯誤,當我試圖執行查詢。數據庫很好,當我將值硬編碼到查詢中時,它工作正常,而不是使用參數。
謝謝。
嘗試改變傳球也許PASSW是越來越混合與ASP標識符... – halocursed 2009-10-08 06:49:08