代码下载:http://download.csdn.net/source/2508693
插入操作:
返回插入ID
返回影响行数
代码
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
}
{
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
}
改:
代码
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
}
{
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
}
查:
代码
<
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 >
< 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 >
代码
//
********************************************无参的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
}
// ********************************************其它的只要给个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
}
删:
代码
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);
}
{
int id = Convert.ToInt32(TextBox7.Text);
lazySQLDAL data = new lazySQLDAL( " testTable " ); // 所在表
bind(); // 绑写repeater
Label3.Text = " 删除行数: " + data.delete( " id " ,id);
}
返回第一行第一列:
代码
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();
}
{
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();
}
检测是否存在:
代码
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
}
{
lazySQLDAL data = new lazySQLDAL( " testTable " ); // 所在表
string str = TextBox9.Text;
data.selectFiled = " one " ; // 字段
data.condition = " one= " + str + "" ; // 条件
Label5.Text = data.chekValue().ToString(); // 返回true 或false
}