Hi,
I am trying to pass parameter value to ODBCCommand object.
but it is not assigning values , the null value is gets stored. i m using following code,
Private Sub cmdsave_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles cmdsave.Click
Dim command As New OdbcCommand
Dim str As String
Dim photo() As Byte = GetPhoto(txtpat h.Text)
str= insert into emp(id, name, photo) values (1,@name,@photo )
command = New OdbcCommand(str , con.cn) ' con.cn is connection object
command.Paramet ers.Add("@name" , OdbcType.VarCha r, 20).Value = "sagar"
command.Paramet ers.Add("@photo ", OdbcType.Image, photo.Length).V alue = photo
command.Execute NonQuery()
msgbox "saved"
End Sub
Public Shared Function GetPhoto(ByVal filePath As String) As Byte()
Dim fs As FileStream = New FileStream(file Path, FileMode.Open, FileAccess.Read )
Dim br As BinaryReader = New BinaryReader(fs )
Dim photo As Byte() = br.ReadBytes(fs .Length)
br.Close()
fs.Close()
Return photo
End Function
Please can anyone help me?
Regards
Programmer2004
I am trying to pass parameter value to ODBCCommand object.
but it is not assigning values , the null value is gets stored. i m using following code,
Private Sub cmdsave_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles cmdsave.Click
Dim command As New OdbcCommand
Dim str As String
Dim photo() As Byte = GetPhoto(txtpat h.Text)
str= insert into emp(id, name, photo) values (1,@name,@photo )
command = New OdbcCommand(str , con.cn) ' con.cn is connection object
command.Paramet ers.Add("@name" , OdbcType.VarCha r, 20).Value = "sagar"
command.Paramet ers.Add("@photo ", OdbcType.Image, photo.Length).V alue = photo
command.Execute NonQuery()
msgbox "saved"
End Sub
Public Shared Function GetPhoto(ByVal filePath As String) As Byte()
Dim fs As FileStream = New FileStream(file Path, FileMode.Open, FileAccess.Read )
Dim br As BinaryReader = New BinaryReader(fs )
Dim photo As Byte() = br.ReadBytes(fs .Length)
br.Close()
fs.Close()
Return photo
End Function
Please can anyone help me?
Regards
Programmer2004
Comment