D
DelmarPT
Guest
I'm learning to adapt code that I use in VBA to work in VB.Net, And I'm having an hard time to figure how to get a value from a query and store it in a String.
I think the connection is working well but unlikne VBA when I try to store the value of a field in the String "Valor", an error happens:
System.TypeLoadException: 'Could not load type 'ADODB.FieldsToInternalFieldsMarshaler' from assembly 'MailService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.'
Sub Main()
Dim VD As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim Valor As String
VD.ConnectionString = "DSN=XXX;UID=XXX;PWD=XXX;"
VD.Open()
RS = VD.Execute("SELECT Cod_PA FROM Tab_SERVICO WHERE Cod_PA='VIADELMAR'")
If Not (RS.BOF And RS.EOF) Then
Valor = RS.Fields("Cod_PA").Value
Else
Valor = "Não existe!"
End If
RS.Close()
VD.Close()
MsgBox(Valor)
End Sub
Continue reading...
I think the connection is working well but unlikne VBA when I try to store the value of a field in the String "Valor", an error happens:
System.TypeLoadException: 'Could not load type 'ADODB.FieldsToInternalFieldsMarshaler' from assembly 'MailService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.'
Sub Main()
Dim VD As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim Valor As String
VD.ConnectionString = "DSN=XXX;UID=XXX;PWD=XXX;"
VD.Open()
RS = VD.Execute("SELECT Cod_PA FROM Tab_SERVICO WHERE Cod_PA='VIADELMAR'")
If Not (RS.BOF And RS.EOF) Then
Valor = RS.Fields("Cod_PA").Value
Else
Valor = "Não existe!"
End If
RS.Close()
VD.Close()
MsgBox(Valor)
End Sub
Continue reading...