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!

adodb connection string

Status
Not open for further replies.

mmarkym

Programmer
Mar 23, 2002
54
US
I have a few ASP pages along with a website on one server that has access to a SQL server database. I've been told that the connection string in the ASP pages to drop tables and query the database is-- connectionstring = "provider='SQLOLEDB'; data source='cecpeople'; initial catalog='Account Name'; user id='Account Name'; password='password'" I'm getting an error that says the requested name (ie tableName) cannot be found.

On another server with access to a SQL server database, I was told the connection string was connectionstring= "Driver={SQL Server};Server=dataserver.cfm-resources.com;db=AccountName;uid=AccountName;pwd=AccountPassword" of course my website is on the first server still. I get an error stating a script timeout!

can anybody help, I've been trying to get this connection for along time

mark
 
The easiest way to check your connection string out is to generate it through the UDL wizard. Here are the steps.


Here is how you invoke the udl wizard. Do this on your desktop.

1. create a blank notepad file.
2. save the file.
3. rename the file by adding a new extention of .udl
make sure you save as all files not txt or some other
file type.
4. the icon for the file should change from notepad to a
little computer - it has now become the wizard.
5. double click on the file and it will bring up a dialog
box with multipule tabs.
6. use the SQL Server provider.
7. look under the ALL tab and there will be parameter settings which you can change if necessary. There is a test
button, press to test the connection.
8. close the file.
9. open the file from notepad instead of double clicking the icon. You will see the connection string which you can copy and paste into your program.
 
Either the previous way, listed in the last post, or save the following text as "MakeConnection.vbs" and then double-click it. When you have made your selections and click OK it will display an input box with your connection string in it.

Dim oDataLinks, sRetVal
On Error Resume Next
Set oDataLinks = CreateObject("Datalinks")
sRetVal = oDataLinks.PromptNew
If Not IsEmpty(sRetVal) Then
InputBox "Your Connection string!", "", sRetVal
End If
Set oDataLinks = Nothing


Chris
 
i don't know if this is the type of coding u want...

'setting up the database connection

dim conn, rs, cmd

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=cecpeople;UID=Account Name;PASSWORD=password;"

set rs = server.CreateObject ("ADODB.recordset")
rs.Open "Select * from ABC", conn, 2, 2

'ABC is the tablename in sql
'Before running the asp page, u should go to the start button --> control panel --> administrative tools --> Data Sources (ODBC) --> click on ADD and add in your database...
 
If you use the .udl and test it it would be succesfull even if the user only has read rights, this means that inserts, updates and dropping tables won't work.

In my opinion the udl way is the best unless you use windows ME (the udl file is not readable).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top