C# 数据库问题 using System.Data; using System.Data.OleDb;
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSy...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Windows.Forms;
namespace thermometric
{
class DalClass
{
static public string ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + Application.StartupPath + @"/myData.mdb";
static private OleDbConnection conn = new OleDbConnection(ConString);
static private OleDbDataAdapter oda = new OleDbDataAdapter();
static public bool Open()
{
try
{
conn.Open();
return true;
}
catch (Exception err)
{
return false;
}
}
static public bool Close()
{
try
{
conn.Close();
return true;
}
catch (Exception err)
{
return false;
}
}
//查询数据
static public DataSet Find(string strSQL)
{
Open();
DataSet myds = new DataSet();
oda = new OleDbDataAdapter(strSQL, conn);
oda.Fill(myds);
Close();
return myds;
}
//更新数据库
static public bool Update(string strSQL)
{
Open();
OleDbCommand mycomd = new OleDbCommand(strSQL,conn);
mycomd.ExecuteNonQuery();
Close();
return true;
}
//插入数据
static public bool Insert(string strSQL)
{
Open();
OleDbCommand mycomd = new OleDbCommand(strSQL, conn);
mycomd.ExecuteNonQuery();
Close();
return true;
}
//删除数据
static public bool Delete(string strSQL)
{
Open();
OleDbCommand mycomd = new OleDbCommand(strSQL, conn);
mycomd.ExecuteNonQuery();
Close();
return true;
}
//获取第一行第一列数据
public static int GetScalar(string strSQL)
{
Open();
OleDbCommand mycomd = new OleDbCommand(strSQL, conn);
int result = (int)mycomd.ExecuteScalar();
Close();
return result;
}
//读取数据
public static OleDbDataReader GetReader(string strSQL)
{
OleDbCommand mycomd= new OleDbCommand(strSQL, conn);
OleDbDataReader reader = mycomd.ExecuteReader();
return reader;
}
}
}
SQL Server数据库 和OleDb区别?从查询数据开始(string strSQL)这又是什么意思?这段程序看不懂,新手提问。 展开
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Windows.Forms;
namespace thermometric
{
class DalClass
{
static public string ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + Application.StartupPath + @"/myData.mdb";
static private OleDbConnection conn = new OleDbConnection(ConString);
static private OleDbDataAdapter oda = new OleDbDataAdapter();
static public bool Open()
{
try
{
conn.Open();
return true;
}
catch (Exception err)
{
return false;
}
}
static public bool Close()
{
try
{
conn.Close();
return true;
}
catch (Exception err)
{
return false;
}
}
//查询数据
static public DataSet Find(string strSQL)
{
Open();
DataSet myds = new DataSet();
oda = new OleDbDataAdapter(strSQL, conn);
oda.Fill(myds);
Close();
return myds;
}
//更新数据库
static public bool Update(string strSQL)
{
Open();
OleDbCommand mycomd = new OleDbCommand(strSQL,conn);
mycomd.ExecuteNonQuery();
Close();
return true;
}
//插入数据
static public bool Insert(string strSQL)
{
Open();
OleDbCommand mycomd = new OleDbCommand(strSQL, conn);
mycomd.ExecuteNonQuery();
Close();
return true;
}
//删除数据
static public bool Delete(string strSQL)
{
Open();
OleDbCommand mycomd = new OleDbCommand(strSQL, conn);
mycomd.ExecuteNonQuery();
Close();
return true;
}
//获取第一行第一列数据
public static int GetScalar(string strSQL)
{
Open();
OleDbCommand mycomd = new OleDbCommand(strSQL, conn);
int result = (int)mycomd.ExecuteScalar();
Close();
return result;
}
//读取数据
public static OleDbDataReader GetReader(string strSQL)
{
OleDbCommand mycomd= new OleDbCommand(strSQL, conn);
OleDbDataReader reader = mycomd.ExecuteReader();
return reader;
}
}
}
SQL Server数据库 和OleDb区别?从查询数据开始(string strSQL)这又是什么意思?这段程序看不懂,新手提问。 展开
3个回答
展开全部
什么意思啊
追问
SQL Server数据库 和OleDb区别?从查询数据开始(string strSQL)这又是什么意思?这段程序看不懂,新手提问。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
查询数据库记录 而后返回值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询