本文发表在 rolia.net 枫下论坛连接是对的, 权限也是有的, DATASET里面的记录也对, 就是最后dp.Update(ds,"phone_address"); 不做。
今天偶漏了什么了?@@
System.Data.SqlClient.SqlConnection form3Con=new System.Data.SqlClient.SqlConnection();
form3Con.ConnectionString=.............................;
System.Data.SqlClient.SqlDataAdapter dp=new System.Data.SqlClient.SqlDataAdapter("select * from phone_address",form3Con);
System.Data.SqlClient.SqlCommandBuilder db=new System.Data.SqlClient.SqlCommandBuilder(dp);
form3Con.Open();
System.Data.DataSet ds=new DataSet( );
dp.Fill(ds,"phone_address");
System.Data.SqlClient.SqlCommand cmd=new System.Data.SqlClient.SqlCommand("INSERT INTO phone_address (PhoneNumber, Name, Street, City,State, PostCode) "+
"Values (@PhoneNumber, @Name, @Street, @City,@State, @PostCode)",form3Con);
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@PhoneNumber", SqlDbType.NVarChar, 14,"PhoneNumer"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Name", SqlDbType.NVarChar, 30,"Name"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Street", SqlDbType.NVarChar, 30,"Street"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@City", SqlDbType.NVarChar, 20, "City"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@State", SqlDbType.NChar, 20, "State"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@PostCode", SqlDbType.NChar, 7, "PostCode"));
cmd.Parameters["@PhoneNumber"].Value=record2.c_PhoneNumber;
cmd.Parameters["@Name"].Value=record2.c_Name;
cmd.Parameters["@Street"].Value=record2.c_Street;
cmd.Parameters["@City"].Value=record2.c_City;
cmd.Parameters["@State"].Value=record2.c_State;
cmd.Parameters["@PostCode"].Value=record2.c_PostCode;
dp.InsertCommand=cmd;
dp.Update(ds,"phone_address");更多精彩文章及讨论,请光临枫下论坛 rolia.net
今天偶漏了什么了?@@
System.Data.SqlClient.SqlConnection form3Con=new System.Data.SqlClient.SqlConnection();
form3Con.ConnectionString=.............................;
System.Data.SqlClient.SqlDataAdapter dp=new System.Data.SqlClient.SqlDataAdapter("select * from phone_address",form3Con);
System.Data.SqlClient.SqlCommandBuilder db=new System.Data.SqlClient.SqlCommandBuilder(dp);
form3Con.Open();
System.Data.DataSet ds=new DataSet( );
dp.Fill(ds,"phone_address");
System.Data.SqlClient.SqlCommand cmd=new System.Data.SqlClient.SqlCommand("INSERT INTO phone_address (PhoneNumber, Name, Street, City,State, PostCode) "+
"Values (@PhoneNumber, @Name, @Street, @City,@State, @PostCode)",form3Con);
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@PhoneNumber", SqlDbType.NVarChar, 14,"PhoneNumer"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Name", SqlDbType.NVarChar, 30,"Name"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Street", SqlDbType.NVarChar, 30,"Street"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@City", SqlDbType.NVarChar, 20, "City"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@State", SqlDbType.NChar, 20, "State"));
cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@PostCode", SqlDbType.NChar, 7, "PostCode"));
cmd.Parameters["@PhoneNumber"].Value=record2.c_PhoneNumber;
cmd.Parameters["@Name"].Value=record2.c_Name;
cmd.Parameters["@Street"].Value=record2.c_Street;
cmd.Parameters["@City"].Value=record2.c_City;
cmd.Parameters["@State"].Value=record2.c_State;
cmd.Parameters["@PostCode"].Value=record2.c_PostCode;
dp.InsertCommand=cmd;
dp.Update(ds,"phone_address");更多精彩文章及讨论,请光临枫下论坛 rolia.net