public New_Employee_Detail()
{
InitializeComponent();
str2 = Update.Text;
con = new OleDbConnection(@"Data Source=COMP5\SQLEXPRESS;Initial Catalog=TNTDB;Integrated Security=True");
con.Open();
dept_text1.Items.Clear();
string OleDb;
if (GlobalClass.EmpID == "admin")
{
OleDb = "SELECT EmpID FROM EmployeeDetails WHERE status IS NULL";
}
else
{
OleDb = "SELECT EmpID FROM EmployeeDetails WHERE EmpID NOT IN('HR001') And status IS NULL";
}
OleDbCommand1 = new OleDbCommand(OleDb, con);
OleDbDataReader dr = OleDbCommand1.ExecuteReader();
while (dr.Read())
{
dept_text1.Items.Add(dr[0]);
count++;
}
dr.Close();
}
Loading
Jignesh TrivediPosted Jan 4, 2012, 5:32 AM
pass provider in connection string.
for example..
con =
hope this help.
new OleDbConnection(@"Data Source=COMP5\SQLEXPRESS;Initial Catalog=TNTDB;Provider=SQLOLEDB;Persist Security Info=True;User ID=test;Password=test");AartiPosted Jan 4, 2012, 4:11 AM
Replace this line
con = new OleDbConnection(@"Data Source=COMP5\SQLEXPRESS;Initial Catalog=TNTDB;Integrated Security=True");
with the below line
OleDbConnection con = new OleDbConnection(@"Data Source=COMP5\SQLEXPRESS;Initial Catalog=TNTDB;Integrated Security=True");
if still error showing of connection string, please check the details provided in connection string.
(@"Data Source=servername;Initial Catalog=DatabaseName;User ID=sa;password=pwd;Integrated Security=True");
Mamta MPosted Jan 3, 2012, 7:06 AM