-
大小: 88KB文件類型: .7z金幣: 2下載: 0 次發布日期: 2021-04-06
- 語言: 數據庫
- 標簽: SQL??ACCESS??WebService??
資源簡介
SQL數據庫和ACCESS數據庫讀寫的WebService。自己根據需求編寫的關于數據庫的WebService。里面涉及到SQL數據庫和ACCESS數據庫的讀寫添加刪除等操作。比較合適的學習資料。帶源碼。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Web;
using?System.Data.OleDb;
using?System.Data;
namespace?WebService1
{
????public?class?Access
????{
????????public?static?string?sqlconstr?=?“Provider=Microsoft.Jet.OLEDB.4.0;?Data?Source=?“;
????????//public?static?string?path?=?System.Windows.Forms.Application.StartupPath?+?“\\“;
????????//public?static?string?constr?=?“Provider=Microsoft.Jet.OLEDB.4.0;?Data?Source=.\\data\\FDATA.mdb“;
????????public?static?string?constr?=?“Provider=Microsoft.Jet.OLEDB.4.0;?Data?Source=G:\\姚向凱\\實驗工廠\\web\\WebService1\\WebService1\\bin\\date\\FDATA.mdb“;
????????///?
????????///?Access?數據庫?打開表的?x?行?y?列
????????///?
????????///?
????????///?
????????///?
????????///?
????????///?
????????public?static?string[]?Access_Open_XY(string?Access_adrstring?biaoint?hangint?lie)
????????{
????????????string?[]?stp=new?string[5];
????????????try
????????????{
????????????????OleDbConnection?mycon?=?new?OleDbConnection(Access_adr);
????????????????mycon.Open();
????????????????OleDbCommand?mycom1?=?mycon.CreateCommand();
????????????????mycom1.CommandText?=?“SELECT?*?FROM?“?+?biao;
????????????????OleDbDataReader?myread1?=?mycom1.ExecuteReader();
????????????????//mycom1.ExecuteScalar();
????????????????int?number?=?0;
????????????????string?temp?=?““;
????????????????while?(myread1.Read())
????????????????{
????????????????????number++;
????????????????????//myread1.GetString(1);
????????????????????if?(hang?==?number)
????????????????????temp?=?myread1[lie].ToString();
????????????????}
????????????????mycon.Close();
????????????????stp[0]?=?“Ture“;
????????????????stp[1]?=?number.ToString();
????????????????stp[2]?=?hang.ToString();
????????????????stp[3]?=?lie.ToString();
????????????????stp[4]?=?temp;
????????????????return?stp;
????????????}
????????????catch?//(Exception?err)
????????????{
????????????????//MessageBox.Show(err.Message);
????????????????stp[0]?=?“Fales“;
????????????????stp[1]?=?““;
????????????????stp[2]?=?hang.ToString();
????????????????stp[3]?=?lie.ToString();
????????????????stp[4]?=?““;
????????????????return?stp;
????????????}
????????}
????????///?
????????///?Access?數據庫?打開表
????????///?
????????///?
????????///?
????????///?
????????public?static?DataTable?Access_Open_biao(string?Access_adrstring?biao)
????????{
????????????DataSet?ds?=?new?DataSet();
????????????DataTable?table?=?new?DataTable();
????????????string?yuju?=?“select?*?from?“+biao;
????????????OleDbDataAdapter?oleDap?=?new?OleDbDataAdapter(yuju?Access_adr);
????????????oleDap.Fill(ds);
????????????oleDap.Dispose();
????????????table?=?ds.Tables[0];
????????????return?t
評論
共有 條評論