How to make database connectivity in asp.net?
Solved/Closed
Digvijaysinh
Posts
10
Registration date
Tuesday January 27, 2009
Status
Member
Last seen
July 6, 2009
-
Updated on Jan 31, 2019 at 03:02 PM
ARVIND - Apr 2, 2018 at 05:23 AM
ARVIND - Apr 2, 2018 at 05:23 AM
Related:
- To access a database from an asp webpage, what initial step must be completed?
- Ms access download - Download - Databases
- If this was you, you won’t be able to access certain security and account settings for a few days. you can still access these settings from a device you’ve logged in with in the past. - Instagram Forum
- How to access google usa - Guide
- Access and downloading - Facebook Forum
- Borland database engine download - Download - Databases
16 responses
Hi,
Please add the following code in your
Step 1: Add Namspace using System.Data.SqlClient;
Step 2: Make Sql connection.
Write this code to create Sql connection:
I hope this should work.
Thanks!
Please add the following code in your
aspx.cspage:
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.
Thanks!
May 26, 2009 at 01:42 AM
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
Jun 17, 2009 at 02:33 AM
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