因为我做的是一个项目,所以数据库操作是单独分开的,
 public static void AddEmployee(Employee employee)
        {
            string strField = "name, officeId, password, cardNumber,gender,nation,religion,homeTown,marriage,politics,eduction,DOB,workPhone,mobile,homePhone,homeAddress,mailingAddress,jobNumber,jobTitle,skillLevel,ID,socailId,entryDate,leaveDate,email,comment,photo";
            string strData = string.Format("'{0}', '{1}', '{2}', '{3}','{4}','{5}','{6}',   '{7}',   '{8}',    '{9}',  '{10}','{11}','{12}',  '{13}','{14}',  '{15}',       '{16}',        '{17}',   '{18}','{19}',   '{20}','{21}', '{22}',   '{23}',  '{24}','{25}','{26}'",
                                                employee.name, employee.officeId, employee.password,employee.cardNumber,employee.gender,employee.nation,employee.religion,employee.homeTown,employee.marriage,employee.politics,employee.education,
                                                employee.DOB,employee.workPhone,employee.mobile,employee.homePhone,employee.homeAddress,employee.mailingAddress,employee.jobNumber,employee.jobTitle,employee.skillLevel,
                                                employee.ID,employee.socailId,employee.entryDate,employee.leaveDate,employee.email,employee.comment,employee.photo);
            sqladd("Employee", strField, strData);
        }我跟踪employee.photo貌似没有值
 m_employee.leaveDate = dtpLeaveDate.Value.ToShortDateString().Trim();
            m_employee.email = textEmail.Text.Trim();
            m_employee.comment = textComment.Text.Trim();
            m_employee.photo = 该怎么写??
        private void btnGetPhoto_Click(object sender, EventArgs e)
        {
            //System.IO.FileStream fs;
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = "D:\\";
            openFileDialog.Filter = "图片文件(*.jpg,*.gif,*.bmp)|*.jpg;*.gif;*.bmp";
            openFileDialog.RestoreDirectory = true;//保存当前路径
            openFileDialog.FilterIndex = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fName = openFileDialog.FileName;
                pbPhoto.Load(fName);//实现图片更改                //图片保存到数据库
                path = openFileDialog.FileName;//文件路径
            }
        }
        private void saveToData()
        {
            //path 如果没有变动的话,值取不到,是否要给个默认值?
            FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
            byte[] photo = new byte[(Int32)stream.Length];
            stream.Read(photo, 0, photo.Length);
            string name = textUserName.Text.ToString();
            string strSql = string.Format("update Employee set photo = '{0}' where employeeId = '{1}'", photo, name);
            SQLServer.SQLInquiry(strSql);
            stream.Close();
        }我处理照片到数据库