Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is Mohit k. Can anyone tell me how to attach database in ado.net project.
I have already created database and tables inside database in sql server..and have created forms in Ado.net. But i am unable to attach the database to my project..here I want to update the data in my database through my project..ie adding the data and delete the data etc through binding navigator....so pls help me..and provide me the solution
Posted
Updated 1-Jul-12 22:56pm
v2
Comments
Shemeer NS 1-Jul-12 12:08pm    
are you working in win form or web form?
Mohit_007 1-Jul-12 12:09pm    
windows
Shemeer NS 1-Jul-12 12:51pm    
OK...
DamithSL 1-Jul-12 12:19pm    
if you have already created database on your sql server why you want to attach it?
You only need to create connection to that database you created on sql server
Mohit_007 1-Jul-12 12:22pm    
yes i have created the conn but after that what to do...should i create new data source?

I think this article will give you all the required information and sample code to perform the CRUD operations using ADO.NET

A Beginner's Tutorial for Understanding ADO.NET[^]
 
Share this answer
 
Check out the Devfusion article here[^] it discusses the ADO.NET and more details like executing commands too if you want.
 
Share this answer
 
You can refer this codeproject article

Add, Edit, and Delete in DataGridView with Paging
 
Share this answer
 
create a connection using SqlConnection class and then you can fire queries using SqlCommand or DataAdapter. Hope this will solve your problem.
 
Share this answer
 
Comments
Mohit_007 2-Jul-12 4:54am    
i have created that conn string but i am getting error on line
"SqlDataReader dr = cmd.ExecuteReader(); "
hari19113 3-Jul-12 13:16pm    
It would be good if you could show the snippet for the same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900