I have a simple dbf file with the name of OTHWAGE.dbf. I can open it in
Visual Studio Server Explorer and see its fields and records by creating a
Data Connection. When I copy the connection string and combine it with code
from VS Help, I end up with the following:
Dim sConnection As String = "Provider=MSDAS QL.1;
Persist Security Info=False;
Data Source=dBASE Files;
Extended Properties=""DS N=dBASE Files;DBQ=C:\Te mp;
DefaultDir=c:\P rogram Files\Microsoft Visual Studio .NET 2003\Common7\ID E;
DriverId=533;Ma xBufferSize=204 8;
PageTimeout=5
;"";
Initial Catalog=C:\Temp "
Dim mySelectQuery As String = "SELECT OTHWAGE.* FROM OTHWAGE"
Dim myConnection As New System.Data.Odb c.OdbcConnectio n(sConnection)
Dim myCommand As New System.Data.Odb c.OdbcCommand(m ySelectQuery,
myConnection)
myConnection.Op en()
Dim myReader As
System.Data.Odb c.OdbcDataReade r = myCommand.Execu teReader()
While myReader.Read()
Console.WriteLi ne(myReader.Get String(1))
End While
For readability purposes, I added carriage returns to the connection string.
When I execute this code, I get a system error at the myConnection.Op en()
line. What I am I doing wrong with this simple code?
Visual Studio Server Explorer and see its fields and records by creating a
Data Connection. When I copy the connection string and combine it with code
from VS Help, I end up with the following:
Dim sConnection As String = "Provider=MSDAS QL.1;
Persist Security Info=False;
Data Source=dBASE Files;
Extended Properties=""DS N=dBASE Files;DBQ=C:\Te mp;
DefaultDir=c:\P rogram Files\Microsoft Visual Studio .NET 2003\Common7\ID E;
DriverId=533;Ma xBufferSize=204 8;
PageTimeout=5
;"";
Initial Catalog=C:\Temp "
Dim mySelectQuery As String = "SELECT OTHWAGE.* FROM OTHWAGE"
Dim myConnection As New System.Data.Odb c.OdbcConnectio n(sConnection)
Dim myCommand As New System.Data.Odb c.OdbcCommand(m ySelectQuery,
myConnection)
myConnection.Op en()
Dim myReader As
System.Data.Odb c.OdbcDataReade r = myCommand.Execu teReader()
While myReader.Read()
Console.WriteLi ne(myReader.Get String(1))
End While
For readability purposes, I added carriage returns to the connection string.
When I execute this code, I get a system error at the myConnection.Op en()
line. What I am I doing wrong with this simple code?
Comment