lazycode SQL类

代码下载:http://download.csdn.net/source/2508693  

 

插入操作:

 

返回插入ID

a1.png

 

返回影响行数 

 aa.png

 

 

 

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
      
protected void Button1_Click( object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox1.Text.Trim());
string b = TextBox2.Text;
DateTime c
= Convert.ToDateTime(TextBox3.Text);
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // testTable 你要插入的表名
data.insertfiled = " one,two,three " ; // 要插入的字段
data.insertvlues = a + " , " + b + " , " + c; // 要插入的参数 注意字段和插入的参数类型和数量要一致
Label1.Text = " 影响行数: " + data.insert(); // 没带参数的返回影响行数
// Label1.Text = "插入字段ID:" + data.insert(true); // 带bool参数的无论是true还是false都返回插入字段ID
}

 

 

 

 

改:

 

a3.png

 

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
      
protected void Button2_Click( object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox5.Text.Trim());
string b = TextBox6.Text;
DateTime c
= Convert.ToDateTime(TextBox8.Text);
int id = Convert.ToInt32(TextBox4.Text);
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // testTable 你要修改的表名
data.updatefiled = " one,two,three " ; // 要修改的字段
data.updatevalues = a + " , " + b + " , " + c; ; // 要修改的参数
Label2.Text = " 修改行数: " + data.update( " id " , id); // 自增主键 ,要修改的id
}

 

 

 

查:

a4.png

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
      
< asp:Repeater ID = " Repeater1 " runat = " server " >
< ItemTemplate >
< div >
< font color = " red " > id: </ font ><% #Eval( " id " ) %>
< font color = " red " > one: </ font ><% #Eval( " one " ) %>
< font color = " red " > two: </ font ><% #Eval( " two " ) %>
< font color = " red " > three: </ font ><% #Eval( " three " ) %></ div >
</ ItemTemplate >
</ asp:Repeater >

 

 

 

 

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
      
// ********************************************无参的getDataSet getDatareader 的需要 selectFiled orderby***************************************************** //
// ********************************************其它的只要给个true就OK如getDatareader(true)***************************************************** //
}
protected void Button1_Click( object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox1.Text.Trim());
string b = TextBox2.Text;
DateTime c
= Convert.ToDateTime(TextBox3.Text);
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // testTable 你要插入的表名
data.insertfiled = " one,two,three " ; // 要插入的字段
data.insertvlues = a + " , " + b + " , " + c; // 要插入的参数 注意字段和插入的参数类型和数量要一致
Label1.Text = " 影响行数: " + data.insert(); // 没带参数的返回影响行数
// Label1.Text = "插入字段ID:" + data.insert(true); // 带bool参数的无论是true还是false都返回插入字段ID
}

 

 

 

 

 

删:

a5.png

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
      
protected void Button3_Click( object sender, EventArgs e)
{
int id = Convert.ToInt32(TextBox7.Text);
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // 所在表
bind(); // 绑写repeater
Label3.Text = " 删除行数: " + data.delete( " id " ,id);
}

 

 

 

 

返回第一行第一列:

a6.png

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
      
protected void Button4_Click( object sender, EventArgs e)
{
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // 所在表
data.condition = " sum(id) " ;
Label4.Text
= data.getScalar().ToString();
}
protected void Button5_Click( object sender, EventArgs e)
{
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // 所在表
data.condition = " avg(id) " ;
Label4.Text
= data.getScalar().ToString();
}
protected void Button6_Click( object sender, EventArgs e)
{
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // 所在表
data.condition = " max(id) " ;
Label4.Text
= data.getScalar().ToString();
}
protected void Button7_Click( object sender, EventArgs e)
{
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // 所在表
data.condition = " count(id) " ;
Label4.Text
= data.getScalar().ToString();
}

 

 

 

检测是否存在:

a7.png

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
      
protected void Button9_Click( object sender, EventArgs e)
{
lazySQLDAL data
= new lazySQLDAL( " testTable " ); // 所在表
string str = TextBox9.Text;
data.selectFiled
= " one " ; // 字段
data.condition = " one= " + str + "" ; // 条件
Label5.Text = data.chekValue().ToString(); // 返回true 或false
}

 

 

 

 

 

 

 

 

posted on 2010-07-02 13:33  lazyCode 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lazycode/archive/2010/07/02/1769871.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值