你完全可以把Excel当数据表一样读出来,然后再写进Sql读Excel的方法:string strConn = "provider=Microsoft.Jet.OLEDB.4.0;data source=Excel文件;Extended Properties=Excel 8.0;";OleDbConnection oleConn = new OleDbConnection(strConn);oleConn.Open();string olestr = "select * from [Sheet1$]";OleDbCommand oleComm = new OleDbCommand(olestr, oleConn);oleComm.Connection = oleConn;OleDbDataAdapter oleDa = new OleDbDataAdapter();oleDa.SelectCommand = oleComm;DataSet ds = new DataSet();oleDa.Fill(ds);foreach (DataRow row in ds.Tables["INFO"].Rows){string userInfo = row[0].ToString().Trim();} oleConn.Close();
给你写个思路吧。FileStream fs=File.Open("C:\\bb.xls",FileMode.Open); byte[] by=new byte[fs.Length]; fs.Read(by,0,(int)fs.Length); String SqlCmd = "UPDATE 表 SET 字段=(@Image) where ...."; SqlCommand CmdObj = new SqlCommand(SqlCmd, conn.myConnection); CmdObj.Parameters.Add("@Image",SqlDbType.Binary, (int)fs.Length).Value = by; fs.Close(); CmdObj.ExecuteNonQuery();