Wednesday, March 21, 2012

how to connect from asp

How do I connect to sql server express from asp.

to sql server I would do as follows but this is not working with sql server express

<%
Dim objconn ,mserver,dbName,UserID_db, PassWD
Dim strCon
Set objconn=Server.CreateObject("ADODB.Connection")
mserver="iphere"
dbName="dbname"
UserID_db="login"
PassWD="password"
strCon="Provider=SQLOLEDB.1;Data Source=" & mServer & ";Initial Catalog=" & _
dbName & ";User ID=" & UserID_db & ";Password=" & PassWD & ";"
objconn.Open strCon
response.write "opened"


%

Did you enabled remote connections for SQl Server Express (this is disabled by default). See the screeencast on my site for more information. SQL Server grabs a dynamically assigned port at startup, so you either specify the port after the servername --> Servername,Portnumber or start SQL Server browser on the server which will redirect the request to the appropiate port.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

Hi,

Also check if NET DDE and NET DDE DSDM services are started under Administrative Tools->Services

and Firewall rules are set properly to allow connection.

Hemantgiri S. Goswami

No comments:

Post a Comment