What to declare a DBNull variable to?

  • Thread starter Thread starter Julian
  • Start date Start date
J

Julian

I need to convert db field values from "1 - Attempted-Successful" to "Yes",
"2 - Attempted-Unsuccessful" to "No" and all other values need to be
NULL-ed. So here's my code:

Dim strQuery As String = "SELECT tblData.CoPayFundGrant,
tblData.M_DSS_SSA_Benefits, tblData.O_DSS_SSA_Benefits, " & _
"tblData.Ref_MPS, tblData.Ref_LA, tblData.Ref_DCMH,
tblData.Place_Comm, tblData.Rem_Comm, tblData.Core_Case_Man,
tblData.Ref_DCMH_Case_Man " & _
"FROM tblData;"
Dim rsDataManip As ADODB.Recordset = cnnJET.Execute(strQuery)
With rsDataManip
If Not .EOF Then
Dim NewDataValue As Object
For Each fldData As ADODB.Field In rsDataManip.Fields
Select Case fldData.Value
Case "1 - Attempted-Successful"
NewDataValue = "Yes"
Case "2 - Attempted-Unsuccessful"
NewDataValue = "No"
Case Else
NewDataValue = System.DBNull


End Select
Next
End If
End With

My question is- what do I declare the temp variable "NewDataValue" as?

PS. Can I do the above using a SQL command?


--
|
+-- Julian
|
+- VB.Net 2003
|
 
Julian said:
I need to convert db field values from "1 - Attempted-Successful" to "Yes",
"2 - Attempted-Unsuccessful" to "No" and all other values need to be
NULL-ed. So here's my code:

Dim strQuery As String = "SELECT tblData.CoPayFundGrant,
tblData.M_DSS_SSA_Benefits, tblData.O_DSS_SSA_Benefits, " & _
"tblData.Ref_MPS, tblData.Ref_LA, tblData.Ref_DCMH,
tblData.Place_Comm, tblData.Rem_Comm, tblData.Core_Case_Man,
tblData.Ref_DCMH_Case_Man " & _
"FROM tblData;"
Dim rsDataManip As ADODB.Recordset = cnnJET.Execute(strQuery)
With rsDataManip
If Not .EOF Then
Dim NewDataValue As Object
For Each fldData As ADODB.Field In rsDataManip.Fields
Select Case fldData.Value
Case "1 - Attempted-Successful"
NewDataValue = "Yes"
Case "2 - Attempted-Unsuccessful"
NewDataValue = "No"
Case Else
NewDataValue = System.DBNull


End Select
Next
End If
End With

My question is- what do I declare the temp variable "NewDataValue" as?

PS. Can I do the above using a SQL command?

Select Case fldData.Value
Case "1 - Attempted-Successful"
NewDataValue = "Yes"
Case "2 - Attempted-Unsuccessful"
NewDataValue = "No"
Case Else
NewDataValue = System.DBNull.Value
End Select
 
My question is- what do I declare the temp variable "NewDataValue" as?
Object?
 
Julian,

You have sent two messages, no problem can happen, but in my opinion is
stephany giving you the extra answer at the other message. I think because
those are more answered, that you keep your questions at that message.

Thanks in advance,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top