c# ACCESS/SQL 部分实现代码
c# ACCESS/SQL 部分实现代码
//执行更新类,返回影响行数的操作
OleDbConnection oconn1 = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + MainForm.MDbFile);
string Sqlstr = string.Format("update clt_list set type='{0}' where id='{1}'", Aphonetype, Aphone);
try
{
oconn1.Open();
OleDbCommand comm1 = new OleDbCommand(Sqlstr, oconn1);
int res = comm1.ExecuteNonQuery();
return res;
}
catch { return 0; }
finally { oconn1.Close();}
//查询/读取类,返回reader(习惯称记录集)
if (Acoid == 0 && Alinkmanid == 0)
return new CallType.PhoneInfo();
CallType.PhoneInfo pPI = new CallType.PhoneInfo();
List<CallType.PhoneInfo.PhoneList> phoneList1 = new List<CallType.PhoneInfo.PhoneList>();
CallType.PhoneInfo.PhoneList tmpList = new CallType.PhoneInfo.PhoneList();
OleDbConnection oconn1 = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + MainForm.MDbFile);
try
{
List<CallType.wpLoginInfo> Userlist = new List<CallType.wpLoginInfo>();
string wheretext = "";
wheretext = wheretext + " and co_id=" + Acoid.ToString();
wheretext = wheretext + " and clt_id=" + Alinkmanid.ToString();
string cmdText = "select autoid, phone_type,phone from clt_phone_list where phone<>'' " + wheretext;
OleDbCommand odcommand = new OleDbCommand(cmdText, oconn1);
oconn1.Open();
OleDbDataReader odReader = odcommand.ExecuteReader();
while (odReader.Read())
{ CallType.wpLoginInfo tmpUser = new CallType.wpLoginInfo();
if (!odReader.IsDBNull(0)) { tmpList.PhoneId = odReader.GetInt32(0); }
if (!odReader.IsDBNull(1)) { tmpList.PhoneType = odReader.GetString(1); }
if (!odReader.IsDBNull(2)) { tmpList.PhoneNum = odReader.GetString(2); }
phoneList1.Add(tmpList);
}
odReader.Close();
pPI.Phone = phoneList1;
return pPI ;
}
catch (Exception)
{
return pPI;
}
finally
{
oconn1.Close();
}