Ok so I made oledb samples from the SQLClient samples I discussed earlier in
the thread. It would give us for writing :
Dim BlobIn(255) As Byte
For i As Integer = 0 To UBound(BlobIn)
BlobIn(i) = CByte(i Mod 255)
Next
Dim Connection As New OleDbConnection(ConnectionString)
Dim Command As New OleDbCommand("INSERT INTO Table1(Blob) VALUES
(?)", Connection)
Connection.Open()
Command.Parameters.Add("a", OleDbType.Binary, UBound(BlobIn)).Value
= BlobIn
Command.ExecuteNonQuery()
For reading :
Dim BlobOut(1024) As Byte
Command = New OleDbCommand("SELECT TOP 1 Blob FROM Table1",
Connection) ' Would select using the PK
Dim Reader As OleDbDataReader = Command.ExecuteReader
Reader.Read()
Debug.Print(Reader.GetBytes(0, 0, BlobOut, 0,
BlobOut.Length).ToString) ' Could stream the result in chunks to a file
For i As Integer = 0 To UBound(BlobIn)
If BlobIn(i) <BlobOut(i) Then MsgBox("Mismatch !")
Next
Connection.Close()
Assuming you have a Table1 table with a Blob field and no records. It alos
test that the fictionous writren blob is the same than the blob we read back
later. From there you should have a starting point allowing to do what you
want...
---
Patrice
"Patrice" <http://www.chez.com/scribe/a écrit dans le message de news:
eT**************@TK2MSFTNGP03.phx.gbl...
Ok the error message is actually misleading as the method name is not
correct. This is actually in the insertion statement where you use to
string that dumps the type name inside the SQL statement resulting in a
SQL syntax error...
Please post a message if you solve the problem. I'll try to post a sample
later today so that you can go back on better tracks...
----
Patrice
"Webbyz" <ma*******@gmail.coma écrit dans le message de news:
11**********************@d57g2000hsg.googlegroups. com...
>Well at this point the GetData is gathering the Data and passing it
into the Db.
Here is the Module for that function.
Module DataAccessModule
Friend Function GetData(ByVal strSQL As String, ByVal TableName As
String) As DataSet
Dim myDataset As DataSet = New DataSet
' Create our connection string
Dim myConnString As OleDbConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=c:
\db1.mdb")
' Create our command
Dim myCommand As OleDbCommand = New OleDbCommand(strSQL,
myConnString)
' Create our data adapter
Dim myDataAdapter As OleDbDataAdapter = New OleDbDataAdapter
' Assign the SQL command to the data adapter
myDataAdapter.SelectCommand = myCommand
Try
' Fill the dataset with the data from our command
myDataAdapter.Fill(myDataset, TableName)
' Return the dataset
GetData = myDataset
Catch ex As OleDbException
MsgBox("An error was thrown by the ADO.Net component in
the GetData function. Error Details: " & _
vbCr & ex.Message, MsgBoxStyle.Exclamation, "Error!")
Debug.WriteLine("SQL Statement: " & strSQL)
GetData = Nothing
Finally
' Close the connection and destroy our connection objects
myCommand.Connection.Close()
myDataset = Nothing
myConnString = Nothing
myCommand = Nothing
myDataAdapter = Nothing
End Try
End Function
Friend Function UpdateData(ByVal strSQL As String) As Integer
' Create our connection string
Dim myConnString As OleDbConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=c:
\db1.mdb")
' Create our command
Dim myCommand As OleDbCommand = New OleDbCommand(strSQL,
myConnString)
Try
' Open the connection
myCommand.Connection.Open()
' execute the SQL
UpdateData = myCommand.ExecuteNonQuery()
Catch ex As OleDbException
MsgBox("An error was thrown by the ADO.Net component in
the GetData function. Error Details: " & _
vbCr & ex.Message, MsgBoxStyle.Exclamation, "Error!")
Debug.WriteLine("SQL Statement: " & strSQL)
UpdateData = Nothing
Finally
' Close the connection and destroy our connection object
myCommand.Connection.Close()
myConnString = Nothing
myCommand = Nothing
End Try
End Function
End Module