?
Solved

URGENT!!! How do I connect to an SQL server via ODBC and VBScript??

Posted on 1998-07-10
9
Medium Priority
?
322 Views
Last Modified: 2010-03-19
I need to connect to a SQL Server (version 6.5) via ODBC from an ASP application. How? All i get is "Invalid login" or "error: 'Undefined'".
Here is a part of the code, maybe It´ll help, though I don´t understand It...

dim login,result
login = SqlLogin
result = SqlSetLUser(login,"username")
result = sqlsetlpwd(login, "password")

As mentioned before this i VERY URGENT!!
0
Comment
Question by:Dempa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 800 total points
ID: 1091715
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=ODBC_NAME;SERVER:Server_Name;UID=User_ID;PWD=password;APP=;DATABASE=Database_Name"


0
 
LVL 28

Expert Comment

by:sybe
ID: 1091716
0
 

Author Comment

by:Dempa
ID: 1091717
Ok, but what is ODBC_NAME? I´ve tried A LOT of different things on that one but so far all i get is this message:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/Con.Net/minitab.asp, line 41

I don't know what to do...
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 28

Expert Comment

by:sybe
ID: 1091718
You will have to make an ODBC to the database.

Control Panel, ODBC32, System DSN, Add, SQL Server, Finish
Then

Give it a name (this the name you will have to use as ODBC_Name)
select the server.
Select the options you want to use. I prefer to use SQL Server authentication
(these things are also mentioned in the ASP statement: servername and user pass)

for the rest defaults are ok


0
 

Expert Comment

by:vinoopauls
ID: 1091719
Try this code:
    I dont think you have to configure the ODBC.

    Set con1 = New ADODb.Connection
    con1.Open ("driver={sql server};
                       server=SERVER NAME;
                       Database=DATABASE NAME;
                       PWD=PASSWORD;
                       UID=User_ID;")

0
 

Author Comment

by:Dempa
ID: 1091720
But I already have an ODBC connection set up on the machine that's running the IIS...do I have to set one up on my machine as well? (My machine is the one running the SQL server)
0
 
LVL 28

Expert Comment

by:sybe
ID: 1091721
No, you need only an ODBC on the machine that is running the server. It should point to the database on your machine

Conn.Open "DSN=ODBC_NAME;SERVER:Server_Name;UID=User_ID;PWD=password;APP=;DATABASE=Database_Name"

Server_Name should be your machine.

The error points clearly to the ODBC, so or your statement which makes the Conn-object contain an error, or the ODBC connection contains an error.

0
 

Expert Comment

by:clique10
ID: 1091722
Just TRY this, like Give a Blank UID=;PWD=; which will pop us the default SQL Login window which shows the DSN Name also then use the sa UID and PWD then If the system Logs in the DSN is OK Else the DSN maybe a Problem of having Different/Unknown Server.

(I EXPERIENCED THIS)
Rarely it may be a Chance of the Event Log Being Filled up OR
TEMPDB has been Choked Up
0
 

Author Comment

by:Dempa
ID: 1091723
Oops, sorry guys i forgot this one...Its working now. I finally got the tip from sybe working so he'll get the points..

Thanx for all your help, I really appriciate it!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question