手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp.net access添加返回自递增id的实现方法第1/3页
asp.net access添加返回自递增id的实现方法第1/3页
摘要:先看界面:添加后数据库:而所要执行的语句:复制代码代码如下:stringname_=this.tbxUseName.Text.Trim();...

先看界面:

asp.net access添加返回自递增id的实现方法第1/3页1

添加后数据库:

asp.net access添加返回自递增id的实现方法第1/3页2

而所要执行的语句:

复制代码 代码如下:

stringname_=this.tbxUseName.Text.Trim();

stringwebname_=this.tbxWebName.Text.Trim();

stringurl_=this.tbxUrl.Text.Trim();

AddFieldItem("news_Title",name_);

AddFieldItem("news_Source",webname_);

AddFieldItem("news_Anthor",url_);

common.salert("添加成功,添加后的ID为"+insert("db_news").ToString());

当我看完小孔子cms对插入数据的处理后,自我感觉.net水平还一直停留在asp中。下面结合代码讲讲:

需要说明的是,小孔子cms在插入时使用的是多层架构,而这篇文章主要着重讲解的是学习,所以我就没弄成多层的了。插入时采用了参数化的过程,类似sql的存储过程;在实际应用中插入数据十分简单,正如上面代码所显示的。

先讲一个类[DbKeyItem]:

复制代码 代码如下:

///<summary>

///数据表中的字段属性:字段名,字段值

///</summary>

publicclassDbKeyItem

{

///<summary>

///字段名称

///</summary>

publicstringfieldName;

///<summary>

///字段值

///</summary>

publicstringfieldValue;

publicDbKeyItem(string_fieldName,object_fieldValue)

{

this.fieldName=_fieldName;

this.fieldValue=_fieldValue.ToString();

}

}

这个类包含两个属性:

1、fieldName:字段名

2、fieldValue:字段值

这个类主要用于:

复制代码 代码如下:

protectedArrayListalFieldItems=newArrayList(10);

///<summary>

///添加一个字段/值对到数组中

///</summary>

publicvoidAddFieldItem(string_fieldName,object_fieldValue)

{

_fieldName="["+_fieldName+"]";

//遍历看是否已经存在字段名

for(inti=0;i<this.alFieldItems.Count;i++)

{

if(((DbKeyItem)this.alFieldItems[i]).fieldName==_fieldName)

{

thrownewArgumentException("字段已经存在");

}

}

this.alFieldItems.Add(newDbKeyItem(_fieldName,_fieldValue));

}

当前1/3页123下一页阅读全文

【asp.net access添加返回自递增id的实现方法第1/3页】相关文章:

asp.net下用url重写URLReWriter实现任意二级域名的方法第1/2页

asp.net为网页动态添加关键词的方法

asp.net操作javascript:confirm返回值的两种方式

asp.net 参数不同共用一个页面的实现方法

asp.net 操作excel的实现代码

把某个asp.net 控件替换成自定义控件的方法

asp.net get set用法第1/2页

asp.net下日期加减的方法

.net 添加Cookie的4种方法

.net get set用法小结第1/3页

精品推荐
分类导航