Solved

mssql db con via web.config

Posted on 2014-10-02
8
83 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
  • 4
  • 2
8 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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 32

Expert Comment

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

Author Comment

by:eaweb
Comment Utility
No, changing the connection still doesn't work.

Can you help me with a connection test page maybe?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

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

Author Comment

by:eaweb
Comment Utility
use asp.net vb
0
 

Author Comment

by:eaweb
Comment Utility
Hi,

Please some help.
Thanks!
0
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
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.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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.

762 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

6 Experts available now in Live!

Get 1:1 Help Now