Link to home
Start Free TrialLog in
Avatar of eaweb
eawebFlag for undefined

asked on

mssql db con via web.config

Hi,

I have the following in a web.config file for a db connection:

<connectionStrings>
        <add
          name="AppUsrConnectionString"
          connectionString="Data Source=CSQL03\BAPPS;Initial
          Catalog=AALSMGNT;Persist Security Info=True;User
          ID=AER;Password=Abc765456"
          providerName="System.Data.SqlClient"
        />
    </connectionStrings>

Based on the above settings i am trying to connect to a mssql 2012 database using the following classic asp vb coding:

Dim strConnection
            strConnection = ConfigurationManager.ConnectionStrings("AppUsrConnectionString").ToString()

to execute below query:

Dim strQueryUserCheckCount
strQueryUserCheckCount = "SELECT count(*) FROM AppUsrD where AppUsr_DWI = '" & Session("UserName") & "'"
'--- build connections for query executions
            Dim objStringDataConnectionStrQueryUserCheckCount
            objStringDataConnectionStrQueryUserCheckCount = New SqlConnection(strConnection)
            objStringDataConnectionStrQueryUserCheckCount.Open()

Dim objConnStrQueryUserCheckCount, userRecordCountCheck
            objConnStrQueryUserCheckCount = New SqlCommand(strQueryUserCheckCount, objStringDataConnectionStrQueryUserCheckCount)
            userRecordCountCheck = objConnStrQueryUserCheckCount.ExecuteScalar()

However i am not able to connect to database. please some help in making it work and in creating a db connection test page.

Thanks in advance
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

You should only need something like

strConnection = "Provider=SQLOLEDB; Server=localhost; database=db_name; uid=user_name; Password=pass_word;"


http://www.connectionstrings.com/sql-server-2012/
also, this looks to be .NET, should probably be moved to that area for better responses
Avatar of eaweb

ASKER

No, changing the connection still doesn't work.

Can you help me with a connection test page maybe?
Avatar of eaweb

ASKER

Hi admin
Please move my question to the .Net area,
Avatar of eaweb

ASKER

use asp.net vb
Avatar of eaweb

ASKER

Hi,

Please some help.
Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial