国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Access > 正文

ACCESS數據庫訪問組件(二)

2024-09-07 19:05:00
字體:
來源:轉載
供稿:網友
access數據庫訪問組件(二)access_table.cs

using system;

namespace xlang.videoonline.framework.database.access
{
/// <summary>
/// summary description for access_datatable.
/// </summary>
public class datatable:system.data.datatable
{
private string _tablename;

private string _primarykey;

public string name
{
get { return _tablename; }
set { _tablename=value; }
}


public string primarykey
{
get { return _primarykey; }
set { _primarykey=value; }
}


public datatable()
{
}


public datatable(string tablename)
{
_tablename=tablename;
}


public string createcommand(database.access.datarow[] rows)
{
string temp="create table "+_tablename+"(";
for(int i=0;i<rows.getlength(0);i++)
{
temp+="["+rows[i].name+"] "+rows[i].type+(rows[i].isnull? ",":" not null,");
}
temp+="constraint [index1] primary key (["+rows[0].name+"]))";
_primarykey=rows[0].name;
return temp;
}


public string insertcommand(database.access.datarow[] rows)
{
string temp="";
temp="insert into "+_tablename+" ( ";
for(int i=0;i<rows.getlength(0);i++)
{
temp+="["+rows[i].name+"] "+",";
}
temp=temp.substring(0,temp.length-1);
temp+=") values(";
for(int i=0;i<rows.getlength(0);i++)
{
if(rows[i].type.equals("boolean"))
temp+=((rows[i].value.tostring().toupper().equals("yes"))? "yes":"no")+",";
else if(rows[i].type.startswith("string")||rows[i].type.equals("memo")||
rows[i].type.equals("text")||rows[i].type.startswith("text"))
temp+="'"+rows[i].value+"',";
else if(rows[i].type.equals("date"))
temp+="#"+rows[i].value+"#,";
else
temp+=rows[i].value+",";
}
temp=temp.substring(0,temp.length-1);
temp+=")";
return temp;
}


public string deletecommand()
{
return "drop table "+_tablename;
}


public string deletecommand(string conditions)
{
return "delete * from "+_tablename+" where "+conditions;
}


public string updatecommand(database.access.datarow[] rows,string conditions)
{
string temp="update "+_tablename+" set ";
temp+=prosessdifferentdatatype(rows);
temp+=" where "+conditions;
return temp;
}


public string selectcommand()
{
return "select * from "+_tablename;
}


public string selectcommand(string conditions)
{
return "select * from "+_tablename +" where "+conditions;
}


public string selectcommand(database.access.datarow[] rows,string conditions)
{
string temp="select ";
for(int i=0;i<rows.getlength(0);i++)
{
temp+="["+rows[i].name+"],";
}
temp=temp.substring(0,temp.length-1);
temp+=" from "+_tablename+" where "+conditions;
return temp;
}


public string joincommand(database.access.datarow[] rows,string condition,params string [] tablenames)
{
string temp="select ";
for(int i=0;i<rows.getlength(0);i++)
{
temp+="["+rows[i].name+"],";
}
temp=temp.substring(0,temp.length-1);
// temp+=" from "+_tablename+" where "+conditions;
temp+=" from ";
foreach(string table in tablenames)
temp+=table+",";
temp=temp.substring(0,temp.length-1);

if(condition!=null)
temp+=" where "+condition;

return temp;
}


private string prosessdifferentdatatype(database.access.datarow[] rows)
{
string temp="";
for(int i=0;i<rows.getlength(0);i++)
{
if(rows[i].type.equals("boolean"))
temp+="["+rows[i].name+"] ="+
((rows[i].value.tostring().toupper().equals("yes"))? "yes":"no")
+",";
else if(rows[i].type.startswith("string")||rows[i].type.equals("memo")||
rows[i].type.equals("text")||rows[i].type.startswith("text"))
temp+="["+rows[i].name+"] ='"+rows[i].value+"',";
else if(rows[i].type.equals("date"))
temp+="["+rows[i].name+"] =#"+rows[i].value+"#,";
else
temp+="["+rows[i].name+"] ="+rows[i].value+",";

}
temp=temp.substring(0,temp.length-1);
return temp;
}
}
}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 石嘴山市| 惠州市| 仁寿县| 阳泉市| 凤凰县| 剑河县| 元朗区| 什邡市| 贺州市| 瑞丽市| 策勒县| 垫江县| 石棉县| 大悟县| 中超| 顺昌县| 金坛市| 南岸区| 通辽市| 西和县| 黎平县| 营口市| 台山市| 仪陇县| 苍南县| 托克逊县| 新邵县| 澜沧| 闵行区| 鹤峰县| 布尔津县| 抚顺市| 东阿县| 萍乡市| 鸡西市| 尖扎县| 迁安市| 会宁县| 唐河县| 龙州县| 龙州县|