c# ACCESS/SQL 部分實現代碼

來源:互聯網
上載者:User

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();
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.