我用的是2005版本的编程软件 可是有一句sqlCmd.Parameters.Add("@IMAGE", buffer)出现警告,请高手指点
Private Sub InsertData()
Dim IDItem(2) As String
IDItem = CmbStuClass.Text.Split(":"c)
Dim StuID As Int16 = Int16.Parse(TxtStuID.Text.Trim)
Dim StuName As String = TxtStuName.Text.Trim
Dim StuSex As String = CmbStuSex.Text.Trim
Dim StuClass As String = IDItem(0)
Dim StuBirthday As Date = DateStuBir.Value
Dim StuCard As String = TxtPerCard.Text
Dim StuPhoto As String = LblPhotoPath.Text.Trim
Dim MyStream As New FileStream(StuPhoto, FileMode.Open, FileAccess.Read)
Dim buffer(MyStream.Length) As Byte
MyStream.Read(buffer, 0, MyStream.Length)
MyStream.Close()
Dim value As String = StuID.ToString + ",'" + StuName + "','" + StuSex + "'," + StuClass + ",'" + StuBirthday + "','" + StuCard + "'"
Dim sql As String = "INSERT INTO STUDENTINFO (STUDENTID, STUDENTNAME,SEX,CLASSID,BIRTHDAY,PERSONCARDID,STUDENTPHOTO) VALUES(" + value + ", @IMAGE)"
Dim sqlCmd As New SqlCommand
sqlCmd.CommandText = sql
sqlCmd.Parameters.Add("@IMAGE", buffer)
sqlCmd.Connection = SqlCon
Try
SqlCon.Open()
sqlCmd.ExecuteNonQuery()
MessageBox.Show("添加记录成功")
Catch ex As Exception
MessageBox.Show("添加记录失败")
WriteErr(ex)
Finally
SqlCon.Close()
End Try
BindData()
End Sub