Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One more easy question tytytyty

Status
Not open for further replies.

Wes98765

Programmer
Jul 31, 2002
135
US
All I have to do now is insert two records into the database. I am used to vb but I have never done anything inside access.

How do I set the connection to the database when I am using a procedure in Access?
 
Here is a function I had to add a table to sql server and it shows a connection string maybe you can get what you need from this example.


Function AddSQLServerTable()
'-- set reference to ADOX library
'- Microsoft ADO Ext. 2.6 for DDL and Security
'-- Microsoft ActiveX data objects 2.6 library also needed for ADO

Dim connString As String
Dim cn As New ADODB.Connection

connString = "provider=SQLOLEDB.1;" & _
"User ID=sa;Initial Catalog=northwind;" & _
"Data Source=bigtuna;" & _
"Persist Security Info=False"
cn.ConnectionString = connString
cn.Open connString
'-- now connected to the sql server database through cn

Dim cg As New ADOX.Catalog
Dim tb As New ADOX.Table
Set cg.ActiveConnection = cn

tb.Name = "Test"
tb.Columns.Append "col1", adInteger
tb.Columns.Append "col2", adVarWChar, 50
cg.Tables.Append tb
Debug.Print "table = "; cg.Tables("Test").Name

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top