Skip to content

Try to connect to sql server DB using ConnectionStringSettings

Supalerk

Asked May 5, 2007, 8:12 AM EDT1 answer
Share
LinkedInX
Hi I am quite new to programming and try to connect to database using System.ConfigurationConnectionStringSettings but meet some error. The following is code and error message. I stuck for sometimes . pls help ---------------------------------------------------------------------------- public DataAccess() { ConnectionStringSettings DatabaseSettings = ConfigurationManager.ConnectionStrings["BookStoreDBConnectionString"]; connection = new SqlConnection("Data Source=supalerk-e843bb;Initial Catalog=BookStoreDB;Integrated Security=True"); GetUsersCmd = new SqlCommand("SPGetUsers", connection); GetUsersCmd.CommandType = System.Data.CommandType.StoredProcedure; GetUsersCmd.Parameters.Add("@Username", System.Data.SqlDbType.VarChar, 50); GetUsersCmd.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50); } ------------------------------------------------------------------------ The error message is Error 10 The type or namespace name 'ConnectionStringSettings' could not be found (are you missing a using directive or an assembly reference?)

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi, Sorry for the messy post last time because that was the first time and I had log in problem for sometime. Here is the better looking code. I already solved that problem which it is because I didn't add assembly reference to my project. public DataAccess() { ConnectionStringSettings DatabaseSettings = ConfigurationManager.ConnectionStrings["BookStoreDBConnectionString"]; connection = new SqlConnection("Data Source=supalerk-e843bb;Initial Catalog=BookStoreDB;Integrated Security=True"); GetUsersCmd = new SqlCommand("SPGetUsers", connection); GetUsersCmd.CommandType = System.Data.CommandType.StoredProcedure; GetUsersCmd.Parameters.Add("@Username", System.Data.SqlDbType.VarChar, 50); GetUsersCmd.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50); } ------------------------------------------------------------------------ The error message is Error 10 The type or namespace name 'ConnectionStringSettings' could not be found (are you missing a using directive or an assembly reference?)
    0