On May 30, 10:42 am, Husam <H...@discussions.microsoft.com> wrote:
> Hi EveryBody:
>
> How can I connect to another database instaed of the default database
> aspnetdb in the local SQL Server in the App_Data folder that exist in my web
> site application ?
>
> My database that I want to connect is in my local Machine and its name=Husam.
>
> Any Help or redirection will be completely appreciated
>
> regard's
>
> Husam
You should connect a database using connection string.
Example of connection string for SQL Server 2000
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated
Security=SSPI;
More examples you can find here
http://www.connectionstrings.com/?carrier=sqlserver
string cs = "Data Source=myServerAddress;Initial
Catalog=myDataBase;Integrated Security=SSPI;"
using (SqlConnection cn = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand();
.....