To start the default instance of SQL Server
1. On the Start menu, point to All Programs, point to Microsoft SQL
Server, and then click SQL Server Configuration Manager.
2. In SQL Server Configuration Manager, expand Services, and then click
SQL Server.
3. In the details pane, right-click SQL Server (MSSQLServer), and then
click Start.
4. A green arrow on the icon next to the server name and on the toolbar
indicates that the server started successfully.
5. Now you can create your own database(ex. name it 'MyDatabaseName' ) .
Add tables to it.
write store procedure to access data from thoes tables.(ex. name it
'spPlanTransportSelect' )
Then In your .Net project in web.config file write following lines to
connect to the SQL Server database:
<configuration>
<connectionStrings>
<remove name=”LocalSqlServer”/>
<add name="MyConnectionString" connectionString="Data Source=localhost; Initial
Catalog=MyDatabaseName; Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
Then In your .Net project on the code behind form use class
provided by microsoft for connection by :
import System.Data.SqlClient;
Then in your function write following lines to connect and use it:
string connectionString =
WebConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
SqlDataAdapter dta = new SqlDataAdapter();
DataSet ds = new DataSet();
conn.Open();
SqlCommand sqlSelect = new SqlCommand("spPlanTransportSelect", conn);
sqlSelect.CommandType =CommandType.StoredProcedure;
dta.SelectCommand = sqlSelect;
dta.Fill(ds, "PlanTransport");
if(conn.State != ConnectionState.Closed)
conn.Close();
Here DataSet ds will conten the data return by database.