用input控件(txtFilePath)查找图片并保存,如果图片在本地电脑则正常保存,在其它机子就出错,同样,如果.net程序在其它电脑,本电脑去运行它保存时也会出错,即程序只能在本机运行保存本机的图片-------------------------------------
SqlDataAdapter da = new SqlDataAdapter("Select * From NewEmployees", conSQL);
SqlCommandBuilder MyCB = new SqlCommandBuilder(da);
DataSet ds = new DataSet("NewEmployees"); da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
string Photo=txtFilePath.Value.ToString();
FileStream fs = new FileStream(@Photo, FileMode.OpenOrCreate, FileAccess.Read);

byte[] MyData= new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));

fs.Close();

da.Fill(ds,"NewEmployees");

DataRow myRow;
myRow=ds.Tables["NewEmployees"].NewRow(); myRow["EMP_N_EMPNO_C"]=txtStaffID.Text;
myRow["EMP_N_EMPNAMEE_NV"] =txtEnName.Text;
myRow["EMP_N_EMPNAMEC_NV"] =txtCnName.Text;
myRow["EMP_N_JOINTDATE_D"] =txtJointDate.Text;
myRow["EMP_N_PROBATIONTO_D"] = txtCancelledDate.Text;
myRow["EMP_N_LOCATION_NV"] = ddlLocation.SelectedItem.Text;
myRow["EMP_N_DEPT_NO_C"] = ddlDepartment.SelectedItem.Text;
myRow["EMP_N_POSITION_NV"] =txtPosition.Text;
myRow["EMP_N_PHOTO_IMA"] = MyData;
ds.Tables["NewEmployees"].Rows.Add(myRow);
da.Update(ds, "NewEmployees");
conSQL.Close();