仓酷云

标题: ASP.NET教程之ACCESS数据库会见组件(二) [打印本页]

作者: 老尸    时间: 2015-1-16 22:31
标题: ASP.NET教程之ACCESS数据库会见组件(二)
有理由相信是能提供更出色的性能。很多平台无法支持复杂的编译器,因此需要二次编译来减少本地编译器的复杂度。当然可能做不到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#的脚步。
作者: 精灵巫婆    时间: 2015-1-19 16:05
现在的ASP.net分为两个版本:1.1和2.0Asp.net1.1用VS2003(visualstudio2003)编程。Asp.net2.0用VS2005(visualstudio2005)编程。现在一般开发用的是VS2003。
作者: 分手快乐    时间: 2015-1-26 16:10
如今主流的Web服务器软件主要由IIS或Apache组成。IIS支持ASP且只能运行在Windows平台下,Apache支持PHP,CGI,JSP且可运行于多种平台,虽然Apache是世界使用排名第一的Web服务器平台。
作者: 爱飞    时间: 2015-2-4 18:57
主流网站开发语言之CGI:CGI就是公共网关接口(CommonGatewayInterface)的缩写。它是最早被用来建立动态网站的后台技术。这种技术可以使用各种语言来编写后台程序,例如C,C++,Java,Pascal等。
作者: 海妖    时间: 2015-2-10 05:22
是目前ASP在UNIX/Linux上的应用可以说几乎为0)。所以平台的局限性和ASP自身的安全性限制了ASP的广泛应用。
作者: 蒙在股里    时间: 2015-2-28 21:31
但是java靠开源打出的一片天地,特别是在微软的垄断下能打开今天的局面还是有它的生命力的。
作者: 山那边是海    时间: 2015-3-17 06:09
JSP/Servlet虽然在国内目前的应用并不广泛,但是其前途不可限量。
作者: 柔情似水    时间: 2015-3-23 22:47
我觉得什么语言,精通就好,你要做的就是比其他80%的人都厉害,你就能得到只有20%的人才能得到的高薪。




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2