Solved

mssql db con via web.config

Posted on 2014-10-02
8
86 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
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 32

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 32

Accepted Solution

by:
Big Monty earned 500 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

911 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

21 Experts available now in Live!

Get 1:1 Help Now