Programming a Database without Objects

G

Guest

I am learning how to do database programming in VB.Net. I would like to know
how to connect to a database programmicly(not sure if thats a word :) instead
of using the connection/data adaptor/dataset objects. I've figured out how to
move trought the database using typed and untyped commands but I'm still not
able to connect to the database without the oleDBconnection object to get the
connection string. The connection string I'm using is:

myconnection.connectionstring = Jet OLEDB:Global Partial Bulk Ops=2;Jet
OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data
Source="C:\Documents and Settings\moorem\Desktop\db1.mdb";Mode=Share Deny
None;Jet OLEDB:Engine Type=5;Provider="Microsoft.Jet.OLEDB.4.0";Jet
OLEDB:System database=;Jet OLEDB:SFP=False;persist security
info=False;Extended Properties=;Jet OLEDB:Compact Without Replica
Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System
Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Jet
OLEDB:Global Bulk Transactions=1

This string was created using the oleDBconnection string wizard....thingy.
(A trick I learned in VB 6.

Any help with this would be greatly appreciated.

Thanks
Mole
 
B

Brian Henry

dim s_ConnectionString = "your connection string here"
dim dbConnection as new OleDB.OleDbConnection(s_ConnectionString)
dim cmdSelect as new OleDB.OleDbCommand("SELECT COUNT(*) FROM TABLE")

dbConnection.Open

cmdSelect.executeScaler() ' execute the SQL command

dbConnection.Close


for example


dim dbConnection as new OleDB.OleDBConnection(connectionString)
 

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

Top