?
Solved

mssql db con via web.config

Posted on 2014-10-02
8
Medium Priority
?
104 Views
Last Modified: 2015-04-15
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
0
Comment
Question by:eaweb
[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
  • 4
  • 2
8 Comments
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 40358198
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/
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 40358207
also, this looks to be .NET, should probably be moved to that area for better responses
0
 

Author Comment

by:eaweb
ID: 40358248
No, changing the connection still doesn't work.

Can you help me with a connection test page maybe?
0
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 

Author Comment

by:eaweb
ID: 40358266
Hi admin
Please move my question to the .Net area,
0
 

Author Comment

by:eaweb
ID: 40366779
use asp.net vb
0
 

Author Comment

by:eaweb
ID: 40581637
Hi,

Please some help.
Thanks!
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 2000 total points
ID: 40581653
it looks like you're using classic asp code, which is entirely different from asp .net. when you do

Dim strQueryUserCheckCount

that's syntax for classic asp, if it was .NET you would have to declare the data type, like this:

Dim strQueryUserCheckCount as String

what's the extension on the web page you're using, fileName.ASP or fileName.ASPX?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

765 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