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

Mamta MRank #268 · 9.4K reputationPosted Jan 3, 2012, 2:06 AM EST
AartiRank #2,383 · 594 reputationPosted Jan 3, 2012, 11:11 PM EST
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");
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 4, 2012, 12:32 AM EST
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");