0% found this document useful (0 votes)
13 views

Connection Strings

This document configures a connection string to access a Microsoft Jet database file and populate a dropdown list with data from a table in that database. It opens a connection using the connection string, executes a query to select all records from the City table, fills a dataset, and binds the dataset to a dropdown list to display the results.

Uploaded by

jeevan7302
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Connection Strings

This document configures a connection string to access a Microsoft Jet database file and populate a dropdown list with data from a table in that database. It opens a connection using the connection string, executes a query to select all records from the City table, fills a dataset, and binds the dataset to a dropdown list to display the results.

Uploaded by

jeevan7302
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

<connectionStrings>

<add name="MyConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source='D:\\Child.mdb'" providerName="System.Data.SqlClient"/>
</connectionStrings>

protected void Page_Load(object sender, EventArgs e)


{
if (!IsPostBack)
{
OleDbConnection m_SqlConnection;
OleDbCommand m_SqlCommand;
OleDbDataAdapter m_SqlDataAdapter;
DataSet ds = new DataSet();
string connectionString =
ConfigurationManager.ConnectionStrings["MyConnectionString"].Connection
String;
using (m_SqlConnection = new
OleDbConnection(connectionString))
{
m_SqlCommand = new OleDbCommand("Select * from City",
m_SqlConnection);
m_SqlDataAdapter = new OleDbDataAdapter(m_SqlCommand);

m_SqlDataAdapter.Fill(ds);

}
//Repeater1.DataSource = ds.Tables[0];
//Repeater1.DataBind();

DropDownList1.DataSource = ds.Tables[0];
DropDownList1.DataBind();
}
}

You might also like