I am new to ADO.NET, having been using ADO in VB6. Most things seem quite manageable, but I am having problems with two aspects. In my application I need to create a database if it does not exist, and in ADO I did it like this:
Dim cat As New ADOX.Catalog
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= FILENAME
and then created a table using:
Dim db As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim sql As String
sql = "CREATE TABLE People (RecNum INT NOT NULL PRIMARY KEY, Surname CHAR(50) NOT NULL);"
db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= FILENAME;
db.Open()
With RS
.ActiveConnection = db
.CursorType = ADODB.CursorTypeEnum.adOpenKeyset
.LockType = ADODB.LockTypeEnum.adLockPessimistic
.Open(sql)
RS = Nothing
End With
db.Close()
db = Nothing
I can still do this in .NET of course, but I'm sure that there must be a tidier way using ADO.NET.
Any help appreciated.
Dim cat As New ADOX.Catalog
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= FILENAME
and then created a table using:
Dim db As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim sql As String
sql = "CREATE TABLE People (RecNum INT NOT NULL PRIMARY KEY, Surname CHAR(50) NOT NULL);"
db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= FILENAME;
db.Open()
With RS
.ActiveConnection = db
.CursorType = ADODB.CursorTypeEnum.adOpenKeyset
.LockType = ADODB.LockTypeEnum.adLockPessimistic
.Open(sql)
RS = Nothing
End With
db.Close()
db = Nothing
I can still do this in .NET of course, but I'm sure that there must be a tidier way using ADO.NET.
Any help appreciated.