人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

用ado+來刪除數據

用ado+來刪除數據

更新時間:2022-08-27 文章作者:未知 信息來源:網絡 閱讀次數:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>

<html>

<script language="VB" runat="server">

Dim MyConnection As SQLConnection

Sub Page_Load(Src As Object, E As EventArgs)

MyConnection = New SQLConnection("server=YOUR-SERVER;uid=joeuser;pwd=joeuser;database=pubs")

If Not (IsPostBack)
BindGrid()
End If
End Sub

Sub MyDataGrid_Delete(Sender As Object, E As DataGridCommandEventArgs)

Dim MyCommand As SQLCommand
Dim DeleteCmd As String = "DELETE from Authors where au_id = @Id"

MyCommand = New SQLCommand(DeleteCmd, MyConnection)
MyCommand.Parameters.Add(New SQLParameter("@Id", SQLDataType.VarChar, 11))
MyCommand.Parameters("@Id").Value = MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))

MyCommand.ActiveConnection.Open()

Try
MyCommand.ExecuteNonQuery()
Message.InnerHtml = "<b>Record Deleted</b><br>" & DeleteCmd
Catch Exp As SQLException
Message.InnerHtml = "ERROR: Could not delete record"
Message.Style("color") = "red"
End Try

MyCommand.ActiveConnection.Close()

BindGrid()
End Sub

Sub BindGrid()

Dim DS As DataSet
Dim MyCommand As SQLDataSetCommand
MyCommand = New SQLDataSetCommand("select * from Authors", MyConnection)

DS = new DataSet()
MyCommand.FillDataSet(DS, "Authors")

MyDataGrid.DataSource=DS.Tables("Authors").DefaultView
MyDataGrid.DataBind()
End Sub

</script>

<body style="font: 10pt verdana">

<form runat="server">

<h3><font face="Verdana">Deleting a Row of Data</font></h3>

<span id="Message" MaintainState="false" style="font: arial 11pt;" runat="server"/><p>

<ASP:DataGrid id="MyDataGrid" runat="server"
Width="800"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
DataKeyField="au_id"
OnDeleteCommand="MyDataGrid_Delete"
>

<property name="Columns">
<asp:ButtonColumn Text="Delete Author" CommandName="Delete"/>
</property>

</ASP:DataGrid>

</form>

</body>
</html>


溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 马龙县| 高碑店市| 泸州市| 五台县| 章丘市| 蒲江县| 商水县| 邹城市| 安多县| 青冈县| 农安县| 清河县| 新乡县| 舒城县| 阿荣旗| 商城县| 翁牛特旗| 美姑县| 库尔勒市| 克什克腾旗| 万全县| 内黄县| 谢通门县| 大洼县| 舞钢市| 台北县| 霍山县| 高青县| 河池市| 道孚县| 博乐市| 巴彦淖尔市| 开封市| 深泽县| 三门县| 清流县| 漯河市| 泗阳县| 新巴尔虎左旗| 密山市| 辛集市|