Hello my friends!
I'm having some problems with binary fields!
I had starter with this script (by Englere):
HERE
This application is for asp.net 2.0 and while read from a datareader insert fields into another database.
I want to use it in asp.net 1.1 to create an huge sql file with all insert lines!
I have a schema datatable that tell what type of data all columns have.
If my sqltype is varchar, nvarchar, int, text, etc... my application do:
Code:
Private Shared Function setParamterTypeAndValue(ByVal table As String, _
ByVal dr As SqlDataReader, _
ByVal col As Integer, _
ByVal sqlProviderType As String, _
ByVal colName As String) As String
Dim result As String = ""
If (sqlProviderType.ToString = "Int") Or _
(sqlProviderType.ToString = "SmallInt") Then
If (dr(col) Is DBNull.Value) Then
result += "NULL, "
Else
result += CType(dr(col), String) & ", "
End If
(...)
ElseIf (sqlProviderType.ToString = "TinyInt") Then
If (dr(col) Is DBNull.Value) Then
result += "NULL, "
Else
result += CType(dr(col), Byte).ToString
End If
ElseIf (sqlProviderType.ToString = "VarChar") Then
If (dr(col) Is DBNull.Value) Then
result += "NULL, "
Else
result += "'" & CType(dr(col), String) & "', "
End If
My big problem is when my sqlType is "binary" !!!!
I have a binary filed on my database with passwords:
(binary / lenght = 20)
I have to do something like:
Code:
ElseIf (sqlProviderType.ToString = "Binary") Then
If (dr(col) Is DBNull.Value) Then
result += "NULL, "
Else
result += CType(dr(col), String) & ", "
End If
But I couldn't use "result += CType(dr(col), String)" when dr(col) is binary!!
I just need to generate a string like :
0xD62F739DA2796769AF9E727E7905F91A369F44A
I spent much time with this without success!
Can anyone tell wath can i do??
Thanks!
Max