ASP.NETな所
TOP
>
MySQL
>
ボタンの設定
TOP
サイトマップ
準備
VWD
標準
データ
検証
ナビゲーション
MySQL
その他
リンク
お問い合わせ
ASP.NET利用準備
IISのインストール
Visual Web Developer 2005 Express Editionのインストール
IISの設定
フォルダのアクセス権の設定
Web Developer 2005 Express Editionのユーザー登録
Hello,world!
クラスの作り方
Label内で改行する
GridViewギャラリー
GridViewの特定のセルのデータを取り出す
RequiredFieldValidator
RangeValidator
RegularExpressionValidator
CompareValidator
CustomValidator
ValidationSummary
Page.IsValid
検証コントロールを無視する
正規表現ひらカナ動作テスト
MenuのEnabledとSelectable
サイトマップの作成
MySQLのインストール
MySQL Server Instance Config Wizard
データベースの作成
MySQL Connector Netのインストール
MySQLのデータベースを制御するクラス
MySQLのデータベースを制御するクラス その2
MySQLのデータベースを制御するクラス 動作テスト
ODBCドライバのインストール
SqlDataSource データソースの設定
SqlDataSource パラメータの設定
SqlDataSource パラメータの設定 その2
ボタンの設定
あいまい検索
MySQL GUI Toolsのインストール
MySQLバックアップスケジュール
コンパイル コマンドライン
リンクについて
リンク集
ThanksgivingSoft
PC設定のコンビニ
ボタンの設定
前のページ
で配置した各ボタンを押したときの動作を設定します。
■SqlDataSource.aspx.vb
Partial Class mysql_SqlDataSource Inherits System.Web.UI.Page [[ 'SELECT ]] Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 'ラベルの初期化 Label1.Text = "" Label2.Text = "" GridView1.DataBind() 'SELECT件数 Dim intSelect As Integer = GridView1.Rows.Count Label1.Text = intSelect End Sub '[[ INSERT ]] Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click 'ラベルの初期化 Label1.Text = "" Label2.Text = "" Dim intInsert As Integer = 0 'INSERT件数 Try 'INSERTの実行 intInsert = SqlDataSource1.Insert() Catch ex As Exception Label2.Text = "INSERTエラー" & ex.Message End Try Label1.Text = intInsert End Sub '[[ UPDATE ]] Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click 'ラベルの初期化 Label1.Text = "" Label2.Text = "" Dim intUpdate As Integer = 0 'UPDATE件数 Try 'UPDATEの実行 intUpdate = SqlDataSource1.Update() Catch ex As Exception Label2.Text = "UPDATEエラー" & ex.Message End Try Label1.Text = intUpdate End Sub '[[ DELETE ]] Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click 'ラベルの初期化 Label1.Text = "" Label2.Text = "" Dim intDelete As Integer = 0 'DELETE件数 Try 'DELETEの実行 intDelete = SqlDataSource1.Delete() Catch ex As Exception Label2.Text = "DELETEエラー" & ex.Message End Try Label1.Text = intDelete End Sub End Class
■SqlDataSource.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="SqlDataSource.aspx.vb" Inherits="mysql_SqlDataSource" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>無題のページ</title> </head> <body> <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SdsMySQL %>" DeleteCommand="DELETE FROM t_sample WHERE aspdotnet = ?" InsertCommand="INSERT INTO t_sample(aspdotnet, natokoro) VALUES (?, ?)" ProviderName="<%$ ConnectionStrings:SdsMySQL.ProviderName %>" SelectCommand="SELECT aspdotnet, natokoro FROM t_sample WHERE (aspdotnet = ?)" UpdateCommand="UPDATE t_sample SET natokoro = ? WHERE aspdotnet = ?" DataSourceMode="DataReader"> <DeleteParameters> <asp:ControlParameter ControlID="TextBox1" Name="newparameter" PropertyName="Text" /> </DeleteParameters> <UpdateParameters> <asp:ControlParameter ControlID="TextBox2" Name="newparameter" PropertyName="Text" /> <asp:ControlParameter ControlID="TextBox1" Name="newparameter" PropertyName="Text" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" Name="newparameter" PropertyName="Text" Type="String" /> </SelectParameters> <InsertParameters> <asp:ControlParameter ControlID="TextBox1" Name="newparameter" PropertyName="Text" /> <asp:ControlParameter ControlID="TextBox2" Name="newparameter" PropertyName="Text" /> </InsertParameters> </asp:SqlDataSource> </div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="aspdotnet" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="aspdotnet" HeaderText="aspdotnet" ReadOnly="True" SortExpression="aspdotnet" /> <asp:BoundField DataField="natokoro" HeaderText="natokoro" SortExpression="natokoro" /> </Columns> </asp:GridView> <asp:Label ID="Label1" runat="server" Text="Label1" Width="400px"></asp:Label><br /> <asp:Label ID="Label2" runat="server" Text="Label2" Width="400px"></asp:Label><br /> TextBox1 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> TextBox2 <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /> <table> <tr> <td style="width: 85px"> Button1</td> <td style="width: 85px"> Button2</td> <td style="width: 85px"> Button3</td> <td style="width: 85px"> Button4</td> </tr> <tr> <td style="width: 85px"> <asp:Button ID="Button1" runat="server" Text="SELECT" Width="80px" /></td> <td style="width: 85px"> <asp:Button ID="Button2" runat="server" Text="INSERT" Width="80px" /></td> <td style="width: 85px"> <asp:Button ID="Button3" runat="server" Text="UPDATE" Width="80px" /></td> <td style="width: 85px"> <asp:Button ID="Button4" runat="server" Text="DELETE" Width="80px" /></td> </tr> </table> </form> </body> </html>
▲UP
<<
SqlDataSource パラメータの設定 その2
あいまい検索
>>
TOP
>
MySQL
>
ボタンの設定
Copyright(C)2006
ThanksgivingSoft
All Rights Reserved
検索用語を入力
検索フォームを送信
Web
サイト内