Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to a database with c#

Status
Not open for further replies.

mellenburg

Programmer
Aug 27, 2001
77
0
0
US
I have the following class in a .aspx.cs file:

public void Page_Load(object sender, EventArgs e)
{
}

Inside this class, I would like to make a connection to a database I created using SQL server managment express edition. I have tried to find an example of connecting to a SQL server DB that works and have not. Can someone tell me the commands necessary to make the DB connection?

In the .aspx file, I created a SQL data source. One of the problems I'm having is I don't know how to determine the connection information, much less the syntax of the statements.

<asp:SqlDataSource
ID="CategoriesSqlDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:BudgetConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:BudgetConnectionString1.ProviderName %>"
SelectCommand="SELECT * FROM Categories ORDER BY SubCategoryID, Category">
</asp:SqlDataSource>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top