A
Adrian Parker
Ok, been having a prob for a bit and was wondering if there were easier ways
of doing some things.
1. If you create an sql statement using a ? in-situ for a parameter, is
there any way of using Command.Parameters.Add() when the value you need to
pass in is null ?
At the moment, I pass an array of objects to a function that adds parms to
the current command object for the connection..
ls_sql = "select * from mytable where x = ? and y = ?"
' build command object then..
AddParms(New Object(){"1",System.DBNull})
Public Command As OleDbCommand
Sub AddParms(ByVal aOBJ() As Object)
Dim lObj As Object
For Each lObj In aOBJ
If Not lObj Is Nothing Then
Select Case lObj.GetType.ToString.ToLower
Case "system.datetime"
Command.Parameters.Add("datetime", OleDbType.DBTimeStamp).Value =
lObj
Case "system.string"
Command.Parameters.Add("string", OleDbType.VarChar).Value = lObj
Case "system.int32"
Command.Parameters.Add("integer", OleDbType.Integer).Value = lObj
Case "system.decimal"
Command.Parameters.Add("decimal", OleDbType.Decimal).Value = lObj
End Select
End If
Next
End Sub
How can I support the System.DBNull ?
2. If you have a record in a db that contains a BLOB, what is the simplest
way of updating that BLOB without using a datatable ?
Many Thanks
Adrian Parker
of doing some things.
1. If you create an sql statement using a ? in-situ for a parameter, is
there any way of using Command.Parameters.Add() when the value you need to
pass in is null ?
At the moment, I pass an array of objects to a function that adds parms to
the current command object for the connection..
ls_sql = "select * from mytable where x = ? and y = ?"
' build command object then..
AddParms(New Object(){"1",System.DBNull})
Public Command As OleDbCommand
Sub AddParms(ByVal aOBJ() As Object)
Dim lObj As Object
For Each lObj In aOBJ
If Not lObj Is Nothing Then
Select Case lObj.GetType.ToString.ToLower
Case "system.datetime"
Command.Parameters.Add("datetime", OleDbType.DBTimeStamp).Value =
lObj
Case "system.string"
Command.Parameters.Add("string", OleDbType.VarChar).Value = lObj
Case "system.int32"
Command.Parameters.Add("integer", OleDbType.Integer).Value = lObj
Case "system.decimal"
Command.Parameters.Add("decimal", OleDbType.Decimal).Value = lObj
End Select
End If
Next
End Sub
How can I support the System.DBNull ?
2. If you have a record in a db that contains a BLOB, what is the simplest
way of updating that BLOB without using a datatable ?
Many Thanks
Adrian Parker