What i'm facing is i dont know what is going wrong to make me continue getting this error:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
Hope to get some direction from all senior
the following is my code:
__________________________________________________ _____________
Expand|Select|Wrap|Line Numbers
- Private Function OpenConn() As Boolean
- myCN = New OleDb.OleDbConnection
- Dim sConnString = "Provider=MSDAORA.1;User ID=123;Password=123;Data Source=test" '
- myCN.ConnectionString = sConnString
- myCN.Open()
- OpenConn = True
- End Function
- ________________________________________________________________
- Private Sub CloseConn()
- If myCN.State = ConnectionState.Open Then
- myCN.Close()
- End If
- End Sub
- _________________________________________________________________
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim openDlg As OpenFileDialog = New OpenFileDialog
- openDlg.Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
- Dim filter As String = openDlg.Filter
- openDlg.Title = "Open a Bitmap File"
- If (openDlg.ShowDialog() = DialogResult.OK) Then
- curFileName = openDlg.FileName
- TextBox1.Text = curFileName
- With PictureBox1
- .Image = Image.FromFile(openDlg.FileName)
- .SizeMode = PictureBoxSizeMode.CenterImage
- End With
- End If
- End Sub
- ________________________________________________________________
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- OpenConn()
- Dim cmd As OleDbCommand
- Dim fs As FileStream
- fs = New FileStream(curFileName, FileMode.Open, FileAccess.Read) ' Read a bitmap contents in a stream
- Dim b(fs.Length - 1) As Byte
- fs.Read(b, 0, b.Length)
- fs.Close()
- cmd = New OleDbCommand("INSERT INTO test (filename, filesave) Values ('" + TextBox1.Text.Substring(TextBox1.Text.LastIndexOf("\") + 1+ "','?')", myCN)
- cmd.Parameters.Add("filesave", OleDbType.VarBinary)
- cmd.Parameters.Item(0).Value() = b
- cmd.ExecuteNonQuery()
- CloseConn()
- MsgBox("New Record inserted.")
- End
- End Sub
- __________________________________________________________________
but don't know how to modify it
Please give me some direction, thanks in advance
** im using microsoft visual studio .net 2003 and 1.1 framework