本文介绍了如何使用Sql ServerAuthentication连接到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法连接到数据库。任何人都可以帮忙吗?直到现在我已经完成了:
I am unable to connect to the database. Can any one please help? Till now I have done:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlobj = new SqlConnection("Data Source = 182.18.175.64 ; Initial Catalog = TamilnaduForestDept ; Login = ***** ; Password = *****; Integrated Security = True");
string sel = "select Status_CommonID,Status_CommonName,Active_Status,EntryBy,EntryDate from Mst_Status_Common";
sqlobj.Open();
SqlDataAdapter adp = new SqlDataAdapter(sel, sqlobj);
DataSet ds = new DataSet();
adp.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ddl_StatusCommon.Items.Add(ds.Tables[0].Rows[i].ItemArray[0].ToString());
}
}
protected void ddl_StatusCommon_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection sqlobj = new SqlConnection("Data Source = 182.18.175.64 ; Initial Catalog = TamilnaduForestDept ; Login = ******; Password = *****; Integrated Security = True");
string sel = "select Status_CommonId,Status_CommonName,Active_Status,EntryBy,EntryDate from office where Status_CommonId = '" + ddl_StatusCommon.SelectedItem.ToString() + "'"; sqlobj.Open();
SqlDataAdapter adp = new SqlDataAdapter(sel, sqlobj);
DataSet ds = new DataSet();
adp.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ddl_StatusCommon.Items.Add(ds.Tables[0].Rows[i].ItemArray[0].ToString());
}
}
推荐答案
这篇关于如何使用Sql ServerAuthentication连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!