'关于分页 只有DATASET可以分页 datagridpagechangedeventargs)
DataGrid1.currentpageindex=e.newpageindex
Rebind()
end sub <datagrid OnPageIndexChanged="datagrid_page">
带有参数的Insert
EventArgs)
dim myconn as sqlconnection=new sqlconnection("server=localhost;uid=sa;pwd=;database=jason")
dim datenow as datetime=DateTime.now
dim moneycount asdecimal=val(textbox1.text)
cmd=New SqlCommand ( " insert into mis values ( @time_now, @Money, '"& textbox2.text &"', '"& textbox3.text &"' ) ", myconn)
cmd.parameters.add("@time_now",datenow)
cmd.parameters.add("@Money",SqlDbType.Decimal).value=moneycount
cmd.connection.open()
cmd.ExecuteNonQuery()
myconn.close()
textbox1.text="" textbox2.text="" textbox3.text="" end sub
EventArgs)
dim myconnection as sqlconnection=new sqlconnection("server=localhost;uid=sa;pwd=123456;database=pub")
dim au_idString asstring="" dim DelString asstring="" dim i asinteger=0 for i=0to MYdatagrid.Items.Count-1 dim h as CheckBox
h=Ctype(MYdatagrid.Items(i).Cells(9).Controls(1),CheckBox)
if h.Checked =truethen au_idString +=" or (au_id ='"+ MYdatagrid.Items(i).Cells(0).Text +"')"'注意cell的数值为参考项的值 endif next if au_idString.Length>0then au_idString=au_idString.Remove(0,4) '移去前四个字符:"or " DelString ="Delete from authors where "+ au_idString
dim DelRec as SqlCommand =new SqlCommand(DelString,myconnection)
DelRec.Connection.Open()
DelRec.ExecuteNonQuery()
DelRec.Connection.Close()
endif end sub <Columns> <asp:BoundColumn DataField="au_id" HeaderText="au_id"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Delete"> <ItemStyle horizontalalign="Center"></ItemStyle> <ItemTemplate> <asp:CheckBox runat="server" ID="del"/> </ItemTemplate> </asp:TemplateColumn> </Columns>
-------------------------------------------------------------------------------- <%@ Page Language="vb" Debug="true" %> -------------------------------------------------------------------------------- )
dim myconn as sqlconnection=new sqlconnection("server=localhost;uid=sa;pwd=;database=jason")
dim mycomm as sqlcommand=new sqlcommand(sqlstr, myconn)
dim dr as sqldatareader
myconn.open()
dr=mycomm.ExecuteReader()
mydatagrid.datasource=dr
mydatagrid.databind()
myconn.close()
end sub -------------------------------------------------------------------------------- )
Dim conn as sqlconnection=new sqlconnection("server=localhost;uid=sa;pwd=123456;database=pub")
Dim CMD As SqlCommand=new SqlCommand(sqlstr,conn)
CMD.Connection.Open()
CMD.ExecuteNonQuery()
CMD.Connection.Close()
end sub -------------------------------------------------------------------------------- )
dim myconnection as sqlconnection=new sqlconnection("server=localhost;uid=sa;pwd=;database=jason")
Dim adapter AsNew SqlDataAdapter()
Dim DS as DataSet =new DataSet()
adapter.SelectCommand =new SqlCommand(sqlstr, myconnection)
myconnection.open()
adapter.fill(ds,"user")
mydatagrid.datasource=ds
mydatagrid.databind()
myconnection.close()
end sub