3 replies
how to connect sql database to asp.net ? what is the code for that ?
#aspnet
  • Profile picture of the author jaythedane
    just add the DB to the project in VS or in WebMatrix

    otherwise you can find the connectionstring here :
    ConnectionStrings.com - Forgot that connection string? Get it here!
    {{ DiscussionBoard.errors[3703606].message }}
  • Profile picture of the author smadso
    just add the connection string.. if your using a sql server database you need to include the security params within the string if your using sql server ce (compact edition) you can link directly to the file.. use server.mappath to get the dynamic web path..
    Signature

    Get your back links indexed in 2 mins
    http://www.imslave.com/LinkBlaster/

    {{ DiscussionBoard.errors[3706674].message }}
  • Profile picture of the author lloydblinks
    string connetionString = null;
    SqlConnection cnn ;
    connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
    cnn = new SqlConnection(connetionString);
    try
    {
    cnn.Open();
    MessageBox.Show ("Connection Open ! ");
    cnn.Close();
    }
    catch (Exception ex)
    {
    MessageBox.Show("Can not open connection ! ");
    }

    you make use of visual studio it will be more easy for u.
    {{ DiscussionBoard.errors[3707798].message }}

Trending Topics