943,922 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 784
  • C# RSS
Feb 8th, 2009
0

ado.net

Expand Post »
hi,

i am trying to create a database driven application using Sql2005 and c#.. i have alittle problem

can anyone tell me how to connect to sql database using c# and do simple transactions such as insert update delete and search ...but it shud be fully code based.

if possible please provide a sample.....
Similar Threads
Reputation Points: 11
Solved Threads: 0
Light Poster
ITech is offline Offline
33 posts
since Jun 2007
Feb 8th, 2009
0

Re: ado.net

Quote ...
but it shud be fully code based.
Friend, if you search on MSDN you'll find a lot of articles there. and you can post here specific question say, when you connect on SQL Server your application releases exception lmlmlma, so the question is "what's the error, friends..."
Best of luck with http://msdn.com
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Feb 8th, 2009
0

Re: ado.net

Just as MSDN is a fine source of information so is Google. Typed in ADO.NET, look what I found!
http://www.codeproject.com/KB/databa...thAdoNet1.aspx
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Feb 9th, 2009
0

Re: ado.net

Click to Expand / Collapse  Quote originally posted by ITech ...
hi,

i am trying to create a database driven application using Sql2005 and c#.. i have alittle problem

can anyone tell me how to connect to sql database using c# and do simple transactions such as insert update delete and search ...but it shud be fully code based.

if possible please provide a sample.....
hi dear nish here

listen with first create database in sql with
create database command
-------------------
after dat when u r writing code in ur .net window
create connection then
open the connection
create command()
set the command type property(in this u have to write select ,insert,delete stt whatever u want)
at last if u want to read something then make datareader object and specify the columns which u made in the sql table
or if uwant to insert ,delete or update something then
simply write---
command object which u made above.execute nonquery
dats it
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nishmay14 is offline Offline
3 posts
since Feb 2009
Feb 10th, 2009
0

Re: ado.net

Reputation Points: 28
Solved Threads: 5
Light Poster
BlackSun is offline Offline
46 posts
since Feb 2008
Feb 10th, 2009
0

Re: ado.net

what happen
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nishmay14 is offline Offline
3 posts
since Feb 2009
Feb 10th, 2009
0

Re: ado.net

Click to Expand / Collapse  Quote originally posted by ITech ...
hi,

i am trying to create a database driven application using Sql2005 and c#.. i have alittle problem

can anyone tell me how to connect to sql database using c# and do simple transactions such as insert update delete and search ...but it shud be fully code based.

if possible please provide a sample.....
Hi,

First add Using System.SqlClient; namespace to your cs file.

Then write connection string like this

//Connection String
SqlConnection conn = new SqlConnection("data source=<NameOfYourSqlServerInstance>;Initial catalog=<NameOfYourDataBase>; username = <UserName>; password =<Password>;Integrated Security=True");

//Insert Method
SqlConnection conn = new SqlConnection("data source=<NameOfYourSqlServerInstance>;Initial catalog=<NameOfYourDataBase>; username = <UserName>; password =<Password>;Integrated Security=True");
SqlCommand cmd = new SqlCommand("InsertQuery",conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();

//Update Method
SqlConnection conn = new SqlConnection("data source=<NameOfYourSqlServerInstance>;Initial catalog=<NameOfYourDataBase>; username = <UserName>; password =<Password>;Integrated Security=True");
SqlCommand cmd = new SqlCommand("UpdateQuery",conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();

//Delete Method
SqlConnection conn = new SqlConnection("data source=<NameOfYourSqlServerInstance>;Initial catalog=<NameOfYourDataBase>; username = <UserName>; password =<Password>;Integrated Security=True");
SqlCommand cmd = new SqlCommand("DeleteQuery",conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Reputation Points: 10
Solved Threads: 0
Newbie Poster
reach2shaik is offline Offline
1 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: input from user help
Next Thread in C# Forum Timeline: backup database code in c#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC