using System;
using System.Data.SqlClient;
class ConnectToSqlConnection {
static void Main(string[] args) {
String sConn = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI";
String sSQL = "select name from Employee";
SqlConnection oConn = new SqlConnection(sConn);
oConn.Open();
SqlCommand oCmd = new SqlCommand(sSQL, oConn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand(sSql);
}
}
}
// Integrated security must set to be 'true' at the place of SCPI if u wan to provide window authentication
No comments:
Post a Comment
thnx