ado.net

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2007
Posts: 33
Reputation: ITech is an unknown quantity at this point 
Solved Threads: 0
ITech's Avatar
ITech ITech is offline Offline
Light Poster

ado.net

 
0
  #1
Feb 8th, 2009
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.....
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: ado.net

 
0
  #2
Feb 8th, 2009
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
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,973
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 286
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: ado.net

 
0
  #3
Feb 8th, 2009
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
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3
Reputation: nishmay14 is an unknown quantity at this point 
Solved Threads: 0
nishmay14 nishmay14 is offline Offline
Newbie Poster

Re: ado.net

 
0
  #4
Feb 9th, 2009
Originally Posted by ITech View 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.....
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 46
Reputation: BlackSun is an unknown quantity at this point 
Solved Threads: 4
BlackSun BlackSun is offline Offline
Light Poster

Re: ado.net

 
0
  #5
Feb 10th, 2009
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3
Reputation: nishmay14 is an unknown quantity at this point 
Solved Threads: 0
nishmay14 nishmay14 is offline Offline
Newbie Poster

Re: ado.net

 
0
  #6
Feb 10th, 2009
what happen
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1
Reputation: reach2shaik is an unknown quantity at this point 
Solved Threads: 0
reach2shaik reach2shaik is offline Offline
Newbie Poster

Re: ado.net

 
0
  #7
Feb 10th, 2009
Originally Posted by ITech View 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.....
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();
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC