I need a help guys, i want to connect my sql database in ASP.net. I had connected microsoft access in java and other language but i hav'nt connected sql in .net technology.I want to use my frontend as ASP.net and backend as sql, please help.
Printable View
I need a help guys, i want to connect my sql database in ASP.net. I had connected microsoft access in java and other language but i hav'nt connected sql in .net technology.I want to use my frontend as ASP.net and backend as sql, please help.
you have to create a new ASP .NET Web Application and name it 'SQLConnection'.Do a ctrl+alt+s shortcut that brings a server explorer window.>browse through
server>yourcomputername>SQLservers>yourinstancename.
click SQL server Instance if you cannot see the instance name right . Leave the default text in the field and new instance will be created using your comptuer name.Now we can connect to MyDB using different authentication. Click right to the database name and choose 'change Login'. uncheck the box "windows NT integrated security" and in the login field enter the login that we created first and choose your password.These are all steps through which you can create a connection.
You can connect your SQL server using SQL authentication in ASP.net. There are few steps through which you can connect your sql in asp.net. To create a secure communication follow the steps:
1) Configuring a connection string.
2) Encrypt the connection string.
3) Configure sql server security.
4) Test security access.
5) secure the communication channel to the database.
By following above steps you can create a connection.
You have to go through some steps for connectivity and you have to write some code for connection.You have to add a following code in your aspx.cs page.
1) Add Namespace "using system.Data.SqlClient"
2) Make sql connection.
You have to write following code:
SqlConnection con = new SqlConnection("Server= your server name or computer name;Database=yourdatabasename;Trusted_Connectopn=True");
SqlCommand cmd = new SqlCommand("write your sql query here eg: select * from table name");
con.Open();
DataSet ds = new DataSet(cmd,con);
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(ds);
con.Close();
Try to run this code, hope this work.
You have to go through some steps for connectivity and you have to write some code for connection.You have to add a following code in your aspx.cs page.
1) Add Namespace "using system.Data.SqlClient"
2) Make sql connection.
You have to write following code:
SqlConnection con = new SqlConnection("Server= your server name or computer name;Database=yourdatabasename;Trusted_Connectopn=True");
SqlCommand cmd = new SqlCommand("write your sql query here eg: select * from table name");
con.Open();
DataSet ds = new DataSet(cmd,con);
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(ds);
con.Close();
Try to run this code, hope this work.