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 :
Make calls from your PC ShowMake calls from your PC Telephone modem CTS Voice Mode Data Mode Call from PC to PC Call with an ADSL modem from PC to phone. Do not mix PSTN and ADSL! With a modem 33 or 56Kb / s, to connect, the modem dials the phone...
Connect a database (MDB) to excel Show[VBA] Connecting a database (MDB) to excel Below is a tips of how to connect an Access database (MDB) in an application excel Add reference Microsoft DAO object librairy X.X In a general module (eg Module1) paste the code below...
LAN, Internet connection: choosing your router ShowLAN,Internet connection:Choosing your Router Intro Case 1 Case 2 Case 3 Options and features to consider Standards required for a WiFi router New Standards Intro A router comes in the shape of a box connected to your computer....
Download I-Newsletter.NET Showi-Newsletter. NET is simply a practical means to manage your mailing lists and publish personalized newsletter by e-mail . i-Newsletter. NET was created from Microsoft Windows ASP.NET framework. i-Newsletter.NET can be installed in your own server,...
Download DBF to PDB (Palm DataBase) Converter ShowDescription The application is designed by WhiteTown Software. DBF to PDB (Palm DataBase) Converter is a tool that allows you to convert your dbf files to pdb format easily. Simple and easy to use, the application has been awarded from various...
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...
RJ11 connector ShowRJ11 Plug The RJ11 connector (RJ for Registered Jack) is the most commonly used connector for telephone lines. It is similar to the RJ45 connector, but smaller. When found on a computer, the RJ11 is generally meant for a modem.
BNC connector ShowBNC connector BNC connectors (Bayonet-Neill-Concelman or British Naval Connector) are connectors for coaxial cables. The BNC family is made up of the following elements: BNC cable connector: is either soldered or crimped to the end of the cable....

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
  • +13

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
  • +3

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
  • +4

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
  • +1

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
  • +1

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