用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();

解决方案 »

  1.   

    我说用的是HTML面版里的file field控件查找图片文件的(txtFilePath)
      

  2.   

    应该是你没有对asp.net用户开通对你上传文件夹的写权限,在iss里添加上就可以了!
      

  3.   

    应该是权限的问题,在服务器保存文件是要对服务器的目录或文件进行读写的,在本机时你有足够的权限作这样的事。
    解决方法:在windows选择你保存文件的目录,右键---〉属性---〉安全--->将aspnet用户添加,并赋予写入的权限
      

  4.   

    错误提示:Server Error in '/jmi' Application.
    --------------------------------------------------------------------------------Logon failure: unknown user name or bad password.我将放.net程序的文件的everyone用户加了写权限,情况还是一样的