判段某一列值是否为空时出现异常。
程序
if (sread["head_picture"]==System.DBNull.Value)
string sql1 = "insert into users (username,passward,permission,head_picture,mypaper) values ('" + name + "','" + passward + "',0,'@images','" + mypaper + "')";
FileStream fs = File.OpenRead(../../image/1.jpg);
byte[] imageb = new byte[fs.Length];
fs.Read(imageb, 0, imageb.Length);
fs.Close();
SqlCommand com3 = new SqlCommand(sql1, conn);
com3.Parameters.Add("@images", SqlDbType.Image).Value = imageb;
if (com3.Connection.State == ConnectionState.Closed)
com3.Connection.Open();
try
{
com3.ExecuteNonQuery();
}为什么把图片存到数据库里数据不对 sql
foreach (DataRow sread in [DataSet对象].Tables[0].Rows)
{
if (sread["head_picture"]== System.DBNull.Value)
{
...
}
}