Question:
how to connect sql database with asp.net through coding.?
Jyotsna
2012-03-07 00:49:45 UTC
how to connect sql database with asp.net through coding.?
Five answers:
?
2012-03-07 01:10:41 UTC
Hi..

I'm assuming you're using visual studio...



1.You create a database in your web site project and add tables.



2. You create a LINQ to SQL object in your project. That has a .dbml extension.



3. You open the .dbml file from within the server/solution explorer.



4. You drag and drop all the tables into the .dbml file area that opens up in step 3, and save it.



5. Whatever name you give to the .dbml file, same name followed by DataContext gives you the name of database context, which you'll use to access the database in the following way:



DatabaseDBDataContext dc = new DatabaseDBDataContext();

UserData ud = dc.UserDatas.Where(x => x.EmpId.ToLower() == txtViewEmp.Text.ToLower()).SingleOrDefault();

EmployeeData emp = dc.EmployeeDatas.Where(x => x.EmpId.ToLower() == txtViewEmp.Text.ToLower()).SingleOrDefault();



Here UserData and EmployeeData are table names & Database DB is name of .dbml or linq file



Hope it helps or at least gives you a direction...
anonymous
2012-03-07 09:33:37 UTC
Are you looking for a website development Delhi company? Finding a web designing and search engine optimization company? WEBEVERON Technologies is a prominent web development Indian company that is offering website designing and development services and solutions.

Visit us at http://www.webeveron.com/ or call us at +91 9311335577 for finding the best solutions.
Matt Anonymous
2012-03-07 09:16:03 UTC
use OOP an create a data access layer
P Bharati: Blogger
2012-03-07 09:04:35 UTC
well,



You have to make the connection properties then set the server properties, now make adapter and statement and execute the statement by connection object.



Thanks
anonymous
2012-03-07 08:56:51 UTC
try to find dome appdev.com course about aps.net , and you will find the processus in details .


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...