Search : in
By :

How to make database connectivity in asp.net

Last answer on Aug 25, 2009 11:54:51 am BST Digvijaysinh, on Jan 29, 2009 8:18:10 am GMT 
 Report this message to moderators

Hello,
i m looking for the database connectivity in asp.net with sql server 2005 or ms access 2007?
please anybody solve my query.
thanks in advance, looking for your response.

Configuration: Windows XP
Microsoft visual studio 2008,C#.

Best answers for « How to make database connectivity in asp.net » in :
Connect your Wii to the Internet ShowConnect your Wii to the Internet Wi-Fi Wi-fi connection (MAC) Detecting Wireless Connection There are two ways to connect his Wii to internet Either wi-fi or USB for those who can not go into wi-fi, Nintendo provides a USB Wi-Fi...
Error Connection (80048820) ShowError Connection (80048820) Solutions Before any configuration on your system, it is recommended that you check the status of MSN Messenger servers to determine if the problem does not come from there:...
Backup/Restore Mysql database ShowBackup/Restore Mysql database Backup Restore your database Note A simple approach on how to backup and restore MySQL databases. Backup To save an existing database it is recommended that you create a dump. To dump all...
Download Database Editor ShowThe database management is a complex task, for the experimented users in general. For a specific task, specific tools are needed. Database editor is a tool allowing fast and easy access to any sorts of database. It will help database developers and...
Sharing an Internet connection ShowAdvantages If you have a local area network (two or more computers connected in a network) with one computer connected to the Internet (via a modem, using a cable, etc.), it may be useful to make the connection accessible to the other computers on...
ODBC ShowWhat is ODBC? ODBC stands for Open Database Connectivity. This is a Microsoft-defined format for communicating between Windows database clients and consumer DBMSs. The ODBC managier can be found in Windows 3.1 and 9x. In Windows 95 and 98, it is...
Creating an ad hoc WiFi network ShowPresentation of the ad hoc WiFi network If you have two or more computers equipped with wireless adapters (WiFi cards), it is possible to easily connect them in a network by setting up a so-called "ad hoc" network, that is, a computer-to-computer...

1

yashmaur, on Jan 29, 2009 10:02:40 am GMT
  • +3

Hi there is al ink by microsoft that i think can help you much on this issue http://www.microsoft.com/sqlserver/2008/en/us/express.aspx

Reply to yashmaur

2

Digvijaysinh, on Jan 29, 2009 10:47:08 am GMT
  • +26

Thanx very much, i think i have got my task right.

Reply to Digvijaysinh

3

dEVELOPER, on Mar 3, 2009 6:50:09 am GMT
  • +14

Hi,
please add the follwoing code in you aspx.cs page.

Step 1 : Add Namspace "using System.Data.SqlClient;"

Step 2 : Make Sql connection.

Write this code to create Sql connection.
SqlConnection con = new SqlConnection("Server=You server name or comp name;Database=Yourdatabasename;Trusted_Connectopn=True");
SqlCommand cmd = new SqlCommand("Write your sql query here eg. select * from Table name");
con.Open();
DataSet ds = new DataSet(cmd,con);
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(ds);
con.Close();

i hope this should work

Reply to dEVELOPER

8

av_deepu, on May 26, 2009 6:42:13 am BST
  • +3

Hello

in a aspx.cs file i write connection string like
System.Data.SqlClient;
SqlConnection conn = new SqlConnection("Data Source=SYS014\ELLE;Initial Catalog=bank;User ID=sa;password=root;Integrated Security=True");

but it is showing error at SYS014\ELLE message is unrecorgnized escape sequence. how to rectify that and how can i connect to database

Reply to av_deepu

10

sachith, on Jun 17, 2009 7:33:28 am BST
  • +1

Hi,

I think your problem is with the "/" character.

SqlConnection conn = new SqlConnection("Data Source=SYS014\ELLE;Initial Catalog=bank;User ID=sa;password=root;Integrated Security=True");

In the above line you use either @ sign in front like this

SqlConnection conn = new SqlConnection(@"Data Source=SYS014\ELLE;Initial Catalog=bank;User ID=sa;password=root;Integrated Security=True");

or

use the '/' sign twice like this.

SqlConnection conn = new SqlConnection("Data Source=SYS014\\ELLE;Initial Catalog=bank;User ID=sa;password=root;Integrated Security=True");

Hope this will solve your problem

Reply to sachith

4

sri, on Mar 13, 2009 9:09:56 am GMT

I am srikamal doing my project work,ihave one problem
my project doing in asp.net
but idont know how to connect the database in asp.net useing vb.
please give the answer my question, urgently.

Reply to sri

5

chinni, on Mar 25, 2009 10:08:12 am GMT
  • +7

Sqlconnection con=new sqlconnection("database=databasename;user id =sa;password=....;")
sqlcommand cmd=new sqlcommand("select * from tablename",con)
con.open()
int i=cmd.executenonquery()
if(i==1)
messagebox.show(".....")
con.close()

like this u can connect to database.

Reply to chinni

7

nithi, on May 14, 2009 1:53:17 pm BST

Hello sir /mam how to cnnecting net from china mobile

Reply to nithi

11

rahul, on Jun 25, 2009 9:21:41 am BST
  • +4

Step 1 : Add Namspace "using System.Data.SqlClient;"

Step 2 : Make Sql connection.

Write this code to create Sql connection.
SqlConnection con = new SqlConnection("Server=You server name or comp name;Database=Yourdatabasename;Trusted_Connectopn=True");
SqlCommand cmd = new SqlCommand("Write your sql query here eg. select * from Table name");
con.Open();
DataSet ds = new DataSet(cmd,con);
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(ds);
con.Close();

Reply to rahul

6

kishore kunal, on Apr 15, 2009 12:19:58 pm BST
  • +5

If you want to make connectivity with sql server on the local system.just define the connection string
sqlconnection con=new sqlconnection("server=. database="specify the datbase in your system",uid=sa;pwd=sa;");



add namespace using system.dat.sqlclient;





happy coding

Reply to kishore kunal

9

Krazoo, on Jun 15, 2009 12:12:16 pm BST
  • +1

System.Data.SqlClient;
SqlConnection conn = new SqlConnection("Data Source=servername;Initial Catalog=DatabaseName;User ID=sa;password=pwd;Integrated Security=True");



Open Connection.
User SqlDataAdapter if

Reply to Krazoo

15

 Tarun nigam, on Aug 25, 2009 11:54:51 am BST

R/s sir
hi
I have used the coonection string format what u had given in ur example but it not able to connect the system.I am usin gVS 2008 n sql server 2005. please reply on my mail nigam_tarun2003@yahoo.co.in. or tarunnigam.tarunnigam@gmail.com. I m in need very much plzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help me.

Reply to Tarun nigam

12

rinki, on Jul 4, 2009 7:39:32 am BST

Reply to rinki

13

QQNeo, on Jul 20, 2009 4:31:30 pm BST

Use a .UDL object, textual edit to see connection string

Reply to QQNeo

14

abhineet, on Aug 25, 2009 9:43:30 am BST
  • +1

I want to get the data base connectivity notes in asp.net

Reply to abhineet