How can connect SQL in .net Frame Work? Give me step by step
How can connect SQL in .net Frame Work? Give me step by step process :)
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anubhav ChaudharyPosted Dec 12, 2013, 2:33 AM
1. First of All Open your .NET, then Add a New WebSite or Project as you wish to.
2. After that Add a new WebForm like this:-
- Right click on your Solution Explorer
- Choose to Add New Item
- Now choose a WebForm and Click on Add Button
3. Now Go to the Server Explorer of your Application.4. Right click on Data Connection and choose to Add Connection.
5. A new Window will get open, here provide your Server Name, if you doesn'y know your Server Name then just write a dot(.) in the Server Name.
6. If your SQL doesn't require any password then click on Windows Authentication but if it require UserName and Password then click on Server Authentication and provide them
7. Now go to the .aspx.cs page of your WebPage
8. Here Add this NameSpace on the top:- using System.Data.SqlClient;
9. Now Add Sql Command and SQL Connection like this:-
SqlConnection x;
10. Now go to the click Button from where you want to execute your code and Add Write code like this:-
11. Data Source=.;Initial Catalog=test;User ID=sa;Password=*******
This thing can be obtained by checking the property of Newly Added Database which you will find in the Server Explorer
I hope I am clear enough.
Jignesh TrivediPosted Dec 12, 2013, 2:28 AM
hi,
Please refer following link it might help you.
http://csharp.net-informations.com/data-providers/csharp-sql-server-connection.htm
http://www.codeproject.com/Articles/4416/Beginners-guide-to-accessing-SQL-Server-through-C
http://msdn.microsoft.com/en-us/library/s4yys16a(v=vs.90).aspx