Access vs SQL database.

assaultkitty
assaultkitty used Ask the Experts™
on
I want to convert this code to connect to a SQL database. Can some one help with this information.  Please provide documentation that would be a great plus!  I am visual.
Global.asax.cs
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
All you should need to do is to replace the connection string with one that references your SQL database. For example:

        protected void Application_Start(object sender, EventArgs e)
        {
            // Get the Total Number of Users from the database.
            string connectionString = @"Provider=SQLNCLI10.1;Integrated Security='';Persist Security Info=False;
                            User ID=sa;Initial Catalog=MyDatabase;Data Source=MySQLServer;Initial File Name='';Server SPN=''";


            string sql = @"SELECT NumberOfHits FROM Counters 
                WHERE CounterType = 'UserCounter'";

Open in new window


This is just a demonstration, you'd have to enter your own details for Server, database, login name/type. And it would be best to specify the connection string as a global variable which you can use rather than specifying it every time you use it.

For more examples of connection strings check this website: http://www.connectionstrings.com/

Author

Commented:
Thank you.  I found out that I was on the wrong track.  I will be back!  Thanks again!

Commented:
You're very welcome, good luck!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial