Solved

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

Posted on 1998-07-10
9
275 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
9 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 200 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql help 8 55
SQL Server - Find Parent/Child relationship tree between numeric range. 7 39
sql server computed columns 11 29
sql select record as one long string 21 21
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now