473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Data base connectivity using c#(ASP.net)

1
HI every body..

I am new for .net field.
I want to now connecting SQL-server with ASP page.
can u plz help me.
Jan 8 '07 #1
5 1316
HI every body..

I am new for .net field.
I want to now connecting SQL-server with ASP page.
can u plz help me.
Hi...
u can have ur application connected to the database in different ways..
either u can use d "SqlDataSource" control..or by using code...
u can use d ctrl mainly for standalone applications..if u use it, specify d
"Configure Data Source" option and then create a new connection...
if u do it by code then u have to use d classes like SqlConnection,
SqlCommand, or SqlDataAdapter, etc...
4 all these import d "System.Data.SqlClient" package...
hope this will help u...
thanx and rgrds...
sand...
Jan 8 '07 #2
aaryan
82
Hi...
u can have ur application connected to the database in different ways..
either u can use d "SqlDataSource" control..or by using code...
u can use d ctrl mainly for standalone applications..if u use it, specify d
"Configure Data Source" option and then create a new connection...
if u do it by code then u have to use d classes like SqlConnection,
SqlCommand, or SqlDataAdapter, etc...
4 all these import d "System.Data.SqlClient" package...
hope this will help u...
thanx and rgrds...
sand...
hi sandeep,
i have the same doubt. cd you just describe it with a small example or direct us to some site which will solve our purpose.
Jan 8 '07 #3
hi sandeep,
i have the same doubt. cd you just describe it with a small example or direct us to some site which will solve our purpose.
Hi..
i will give u a sample code..

using System.Data.SqlClient; // importing d needed package

//now within d corresponding function(for eg. Button_Click) have the code like,

SqlConnection cn = new SqlConnection(); // creating a connection variable

String sqlQuery;

cn.ConnectionString = "ur connection string"

sqlQuery = "create table temp(no int,name nvarchar(50))";

cn.Open(); //opening d conn.

SqlCommand sqlcmd = new SqlCommand(sqlQuery, cn); //sqlcommand obj to execute d queries...

sqlcmd.ExecuteNonQuery(); //executing d query and now d table will b created...

cn.Close(); //closing d conn.

sqlQuery = "insert into temp values(1,'Mak')";

cn.Open();

sqlcmd.CommandText=sqlQuery;

sqlcmd.ExecuteNonQuery(); //executing insert query...

cn.Close();

And to have the data displayed in a ctrl like gridview u can use
SqlDataReader() class like,

SqlCommand sqlcmd;

sqlQuery="select * from temp";

cn.open();

sqlcmd = new SqlCommand(sqlQuery, cn);

SqlDataReader sreader = sqlcmd.ExecuteReader();

tempView.DataSource = sreader; //where tempView is ur GridView..

tempView.DataBind();

cn.close();


i think d following url will b helpful to u...

http://www.codeproject.com/useritems/SQLConnect.asp

and also u may get some good videos on "asp.net/learn/videos/"

thanx and rgrds,
sand...
Jan 9 '07 #4
aaryan
82
thanks sandeep,
it was clear and simple. thanks a lot for your prompt reply.
Jan 9 '07 #5
thanks sandeep,
it was clear and simple. thanks a lot for your prompt reply.
thanx..
keep going :) Good Luck...
Jan 9 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Stylus Studio | last post by:
Stylus Studio 6 XML Enterprise Edition Now Integrates with TigerLogic XDMS XQuery and Native XML Database Bedford, MA, -- Stylus Studio ( http://www.stylusstudio.com ), the industry-leading...
0
by: Stylus Studio | last post by:
DataDirect XQuery(TM) is the First Embeddable Component for XQuery That is Modeled after the XQuery API for Java(TM) (XQJ) BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies...
9
by: Tony Lee | last post by:
Some time a ago, on this newsgroup the following comments were made in recommending good references for Access (2003) >I used to recommend Dr. Rick Dobson's, "Programming Access <version>" for...
2
by: Nu2ASP.NET | last post by:
What I am trying to do is essentially 'flip' the bits, when the user clicks in the checkbox. For example, if the CheckBox appears checked, and the user un-checks it, I want the underlying data...
5
by: rogsonl | last post by:
My computer was moved last week, and the company changed the network groups we work on. As a result, one of the main benefits from Whidbey (database connectivity) no longer works. Situation: 1....
2
by: Hugh Welford | last post by:
Hi - using asp to connect to ACCESS data bases on-line. Does ACCESS or a server behave like ACCESS on a local machine? - in particular are there the same query performance advantages in applying...
6
by: Senthil | last post by:
Hi All We are having a VB application on SQL. But we need to collect information from persons who will be offline to verify data and insert new data. Generally they will be entering the data in...
5
by: Will | last post by:
- I know enough ASP and Access to be dangerous :) - I need to put up a data base on our web server with 3 related tables. - They will be accessed by a limited number of people. - Each user will...
2
by: navneetkhehra | last post by:
hi....to all respectable members.i m a beginner in .net.i want ur help.i am not able to make connectivity of asp.net with sqlserver.plz provide me help.m waiting
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.