|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
有理由相信是能提供更出色的性能。很多平台无法支持复杂的编译器,因此需要二次编译来减少本地编译器的复杂度。当然可能做不到java编译器那么简易。access|会见|数据|数据库ACCESS数据库会见组件(二)ACCESS_Table.cs
usingSystem;
namespaceXLang.VideoOnline.Framework.Database.Access
{
///<summary>
///SummarydescriptionforACCESS_DataTable.
///</summary>
publicclassDataTable:System.Data.DataTable
{
privatestring_tableName;
privatestring_primaryKey;
publicstringName
{
get{return_tableName;}
set{_tableName=value;}
}
publicstringPrimaryKey
{
get{return_primaryKey;}
set{_primaryKey=value;}
}
publicDataTable()
{
}
publicDataTable(stringtableName)
{
_tableName=tableName;
}
publicstringCreateCommand(Database.Access.DataRow[]rows)
{
stringtemp="CREATETABLE"+_tableName+"(";
for(inti=0;i<rows.GetLength(0);i++)
{
temp+="["+rows[i].Name+"]"+rows[i].Type+(rows[i].IsNull?",":"notnull,");
}
temp+="CONSTRAINT[Index1]PRIMARYKEY(["+rows[0].Name+"]))";
_primaryKey=rows[0].Name;
returntemp;
}
publicstringInsertCommand(Database.Access.DataRow[]rows)
{
stringtemp="";
temp="INSERTINTO"+_tableName+"(";
for(inti=0;i<rows.GetLength(0);i++)
{
temp+="["+rows[i].Name+"]"+",";
}
temp=temp.Substring(0,temp.Length-1);
temp+=")VALUES(";
for(inti=0;i<rows.GetLength(0);i++)
{
if(rows[i].Type.Equals("boolean"))
temp+=((rows[i].Value.ToString().ToUpper().Equals("YES"))?"yes":"no")+",";
elseif(rows[i].Type.StartsWith("string")||rows[i].Type.Equals("memo")||
rows[i].Type.Equals("text")||rows[i].Type.StartsWith("text"))
temp+=""+rows[i].Value+",";
elseif(rows[i].Type.Equals("date"))
temp+="#"+rows[i].Value+"#,";
else
temp+=rows[i].Value+",";
}
temp=temp.Substring(0,temp.Length-1);
temp+=")";
returntemp;
}
publicstringDeleteCommand()
{
return"DROPTABLE"+_tableName;
}
publicstringDeleteCommand(stringconditions)
{
return"DELETE*FROM"+_tableName+"WHERE"+conditions;
}
publicstringUpdateCommand(Database.Access.DataRow[]rows,stringconditions)
{
stringtemp="UPDATE"+_tableName+"SET";
temp+=ProsessDifferentDataType(rows);
temp+="WHERE"+conditions;
returntemp;
}
publicstringSelectCommand()
{
return"SELECT*FROM"+_tableName;
}
publicstringSelectCommand(stringconditions)
{
return"SELECT*FROM"+_tableName+"WHERE"+conditions;
}
publicstringSelectCommand(Database.Access.DataRow[]rows,stringconditions)
{
stringtemp="SELECT";
for(inti=0;i<rows.GetLength(0);i++)
{
temp+="["+rows[i].Name+"],";
}
temp=temp.Substring(0,temp.Length-1);
temp+="FROM"+_tableName+"WHERE"+conditions;
returntemp;
}
publicstringJoinCommand(Database.Access.DataRow[]rows,stringcondition,paramsstring[]tableNames)
{
stringtemp="SELECT";
for(inti=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(stringtableintableNames)
temp+=table+",";
temp=temp.Substring(0,temp.Length-1);
if(condition!=null)
temp+="WHERE"+condition;
returntemp;
}
privatestringProsessDifferentDataType(Database.Access.DataRow[]rows)
{
stringtemp="";
for(inti=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")
+",";
elseif(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+",";
elseif(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);
returntemp;
}
}
}
也许C#刚上市的时候有些抄袭Java吧,但自从C#2.0上市之后,整个局面就扭转乾坤了,不但Java在模仿C#,而且他从来都没能跟得上C#的脚步。 |
|