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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL language used with ADO controls and no database connection

Status
Not open for further replies.

ChasBags

Programmer
Sep 8, 2000
1
US
I'am a student learning V.B. and SQL and my assignment is to create a form, and use ADO & SQL. Using single form and using ADO controls. I am coding to establish a connection to my database in 'form load procedure'. ADO controls are set to cmdText and using 'select from' in record source. I've coded for ADODB.Connection & ADODB.Command. In 'form load' coded for .ConnectionString and .Open and .ActiveConnection and .CommandType. My database is where my ADO controls find it, but when I run the application an error message comes up with "can't find file/database" with debugging showing me it is in my .Open coding. If ADO finds my database why not SQL code in 'form load' procedure? [sig][/sig]
 
It could depends on the kind of database you are trying to connect to.

But you could do this that is very simple:

1. Make an ODBC Connection to your database. The ODBC Connection will contain all the information needed to build a connection string.

2. Then try to connect doing somewhat like this:

oConnection.Open "DSN=MyODBCConnection"


Building a connection string depends on the connection settings for a particular database. In SQL Server I do somewhat like this:

oConnection.Open "Driver={SQL Server};UID=SA;PWD=;DATABASE=NorthWind;SERVER=(local)"

[sig]<p>Edwin Dalorzo<br><a href=mailto:edalorzo@hotmail.com>edalorzo@hotmail.com</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top