仅有的40分,问一个asp.net中的插入语句,弱的要死,救我啊啊
今天心戳类
图书馆借的书突然不见了的说
做个语句老半天不会
又没有书
string SQL="INSERT INTO Image (img_name,img_data,img_contenttype) VALUES ( @img_name, @img_data,@img_contenttype )";
//这里我写成string SQL="INSERT INTO Image(婆婆,img_name,img_data,img_contenttype)VALUES("+
1+","//字段存在与否不是问题,我可以在表里添,
@img_name+","+
@img_data+","
@img_contenttype ")";
//可以否,这里的img_name和@img_name中的img_name是否一定要一样的说,因为偶想要这些和别的数据一同添加到数据库上去的说
System.Data.SqlClient.SqlCommand command=new System.Data.SqlClient.SqlCommand ( SQL,connection );
System.Data.SqlClient.SqlParameter param0=new System.Data.SqlClient.SqlParameter ( "@img_name", SqlDbType.VarChar,50 );
param0.Value = imgName;
command.Parameters.Add( param0 ); //这个语句块不懂的说,是否跟上面的sql语句有关的说,不是//我没有看联机说明
//是看不懂的说,望大哥们帮帮小弟,万分感谢
System.Data.SqlClient.SqlParameter param1=new System.Data.SqlClient.SqlParameter ( "@img_data", SqlDbType.Image );
param1.Value = imgbin;
command.Parameters.Add( param1 );
System.Data.SqlClient.SqlParameter param2 =new System.Data.SqlClient.SqlParameter ( "@img_contenttype", SqlDbType.VarChar,50 );
param2.Value = imgcontenttype;
command.Parameters.Add( param2 );