Jump to content

how to create database referece for sql server 200 on remote server


sansat6699

Recommended Posts

hii have a problem want to add database reference of remote server database without attaching databse to project solution. and another problem is whenever i attach my sql2000 databse file to my project when i use login control it crate another aspnet.db file in project folder and make username an other entries in that aspnetdb.mdf file. i want all entries in my own attached file. i processed my database file with aspnetregsql tool to create all necessary tables and successsfully created all required tables in the .mdf file. but whenever i create new user .net create another .mdf file for user information i need healp pleasethank you,

Link to comment
Share on other sites

Every .NET website that I've built uses a remote connection to a database; be that MS SQL or MySQL. I can't say that I've ever had to attach the database to the project (whatever that might entail) nor have I ever seen anything added to the AppData directory of any of my projects.I do what aspnetguy suggests which is to add a connection string to my web.config file and use that connection string to create a connection to the database in the code. If you are using SQL Server, the code would look something like this:

SqlConnection conn = new SqlConnection("myconnectionstring");conn.Open();SqlCommand command = new SqlCommand("SELECT * FROM MyTable", conn);DataTable table = new DataTable();SqlDataAdapter sda = new SqlDataAdapter(command);sda.Fill(table);sda.Dispose();command.Dispose();conn.Close();conn.Dispose();

For more help on finding your connection string, check out this helpful site:http://www.connectionstrings.com/

Link to comment
Share on other sites

Every .NET website that I've built uses a remote connection to a database; be that MS SQL or MySQL. I can't say that I've ever had to attach the database to the project (whatever that might entail) nor have I ever seen anything added to the AppData directory of any of my projects.I do what aspnetguy suggests which is to add a connection string to my web.config file and use that connection string to create a connection to the database in the code. If you are using SQL Server, the code would look something like this:
SqlConnection conn = new SqlConnection("myconnectionstring");conn.Open();SqlCommand command = new SqlCommand("SELECT * FROM MyTable", conn);DataTable table = new DataTable();SqlDataAdapter sda = new SqlDataAdapter(command);sda.Fill(table);sda.Dispose();command.Dispose();conn.Close();conn.Dispose();

For more help on finding your connection string, check out this helpful site:http://www.connectionstrings.com/

thank you man but i wonder as i am new to asp.net which sites or resources are healpfull for newfies in asp.net can anybody provide me
Link to comment
Share on other sites

Well, other than the very basic tutorial here at W3Schools, one of the sites I frequented a lot while learning was Code Project:http://www.codeproject.com/aspnet/If I were looking to learn about database connections, I would browse through their articles regarding databases. Now that I have 4 or 5 years of experience in ASP.NET, I stick to Microsoft's MSDN site and Google searches.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...