This is a very large question. You can connect to a MS SQL server by using a
native datasource like this:
// The connection string, using Windows Authentication
System.Data.SqlClient.SqlConnection _con =
new System.Data.SqlClient.SqlConnection( "Data
Source=(local)\\MINDB;Initial Catalog=BMWCCN;Integrated Security=SSPI;" );
// Create a command for the SQL sentence.
System.Data.SqlClient.SqlCommand _cmd = _con.CreateCommand();
// Write the SQL sentence.
_cmd.set_CommandText( "SELECT * FROM Forum Where Toppnode = 1" );
// Make an dataAdapter for the sql command.
System.Data.SqlClient.SqlDataAdapter _dataAdapter = new
System.Data.SqlClient.SqlDataAdapter( _cmd );
// The result table.
System.Data.DataTable _dataTable = new System.Data.DataTable();
// Fill the result into the result table
_dataAdapter.Fill( _dataTable );
// Show the result to the user, using a DataGrid GUI component.
this.dataGrid1.set_DataSource( _dataTable );
We have two ways of connection to a SQL server, Windows authentication
(trusted connection) and SQL authentication. You can find the connection
strings on this web page: Please use Windows authentication for more
security. SQL authentication will send the login and password in plain text
over the network and can be sniffed by network packet sniffers.
http://www.connectionstrings.com/ Regards,
Lars-Inge Tønnessen