|
-
May 13th, 2004, 07:31 PM
#1
Thread Starter
Lively Member
[RESOLVED] Fill a dataset from a SQL table with a binary field.
How can I do this? It gives me an error saying: Inconvertable type mismatch between SourceColumn 'Hash' of Byte[] and the DataColumn 'Hash' of String.
KT
Last edited by Kt3; May 14th, 2004 at 08:07 AM.
-
May 14th, 2004, 07:26 AM
#2
Retired VBF Adm1nistrator
Try converting the byte array to a string
VB Code:
Dim bytByte() As Byte, strString As String
Dim myEncoding As New System.Text.ASCIIEncoding()
strString = myEncoding.GetString(bytByte)
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
May 14th, 2004, 08:05 AM
#3
Thread Starter
Lively Member
I used the sql datareader instead and created a new field entry for each column in an added row. Casting the binary field data as a byte() array type worked fine! In any case, I really appreciate you replying with a suggestion.. You da man..
KT
VB Code:
Public Sub GetSubmitted(ByVal dataset As DataSet)
Dim con As New SqlConnection(ConnectionString)
Dim cmd As New SqlCommand("GetSubmitted", con)
Dim param As SqlParameter
cmd.CommandType = CommandType.StoredProcedure
Dim r As SqlDataReader
Dim Table As DataTable = dataset.Tables(0)
Try
con.Open()
r = cmd.ExecuteReader
Do While r.Read
Dim row As DataRow = Table.NewRow
row("ID") = CType(r("ID"), Integer)
row("Time") = CType(r("Time"), DateTime)
row("Tracker") = CType(r("Tracker"), String)
row("TrackerType") = CType(r("TrackerType"), Integer)
row("Hash") = CType(r("Hash"), Byte())
row("Section") = CType(r("Section"), String)
row("Name") = CType(r("Name"), String)
row("Description") = CType(r("Description"), String)
row("Size") = CType(r("Size"), Integer)
row("Seeds") = CType(r("Seeds"), Integer)
row("Peers") = CType(r("Peers"), Integer)
row("InfoUrl") = CType(r("InfoUrl"), String)
Table.Rows.Add(row)
Loop
Finally
con.Close()
End Try
End Sub
Last edited by Kt3; May 14th, 2004 at 08:09 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|