Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   using asp.net ? (https://www.warriorforum.com/programming/364272-using-asp-net.html)

iamroberts 13th April 2011 09:30 PM

using asp.net ?
 
how to connect sql database to asp.net ? what is the code for that ?

jaythedane 14th April 2011 03:03 AM

Re: using asp.net ?
 
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!

smadso 14th April 2011 01:26 PM

Re: using asp.net ?
 
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..

lloydblinks 14th April 2011 05:10 PM

Re: using asp.net ?
 
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.


All times are GMT -6. The time now is 11:26 AM.