Loading ...

connecting to sql server 2008 from visual studio 2008

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  client side web development   » connecting to sql server 2008 from visual studio 2008

connecting to sql server 2008 from visual studio 2008

Posts under the topic: connecting to sql server 2008 from visual studio 2008

Posted: 11/7/2011

Lurker 245  points  Lurker
  • Joined on: 4/15/2011
  • Posts: 44

Hello

I have created a database Example in sql server 2008
now I want to connect this DB in Visual studio 2008

so I had followed the following steps :-
 1. On server explorer right click on Data Connections select Add Connection
 2. choose Data Sourse as Microsoft SQL Server & Data Provider as  .Net framework data provider for sql
 3. Then add server name example: myComputerName\SQLEXPRESS
 4. when I choose Select or enter database name option at this point it's not showing me Example database
    but showing only system database names (master,model,msdb,tempdb) I am using windows authencation
why it is not showing Example database name into dropdownlist
how to resolve this problem please help me


Posted: 1/9/2012

Lurker 30  points  Lurker
  • Joined on: 11/27/2011
  • Posts: 2

Hi,

 

You can use write this code in web.config file .

<connectionString>

<add name="conn" connectionstring="server=your servername;database=database name;uid=your username;pwd=your password" Provider="System.Data.SqlClient" />

</connection string>

 

Regards

Websoftcreation,Jaipur


tags Sql, 2008, server

Posted: 1/10/2012

Professional 8338  points  Professional
  • Joined on: 4/15/2009
  • Posts: 424
  Answered

The easiest way to determine the actual connection string is to use the SqlDataSource. configure the control by following the wizard and point the database location that you want to use. You can then copy the connection string generated in the SqlDataSource and use it as the connection string. You can even bind your SqlDataSource directly to your dropdownlist if you wish to.

Also you may want to take a look at this link for more details about connecting your database from Visual Studio.

http://msdn.microsoft.com/en-us/library/ms171886%28v=vs.80%29.aspx


Page 1 of 1 (3 items)