Webページにボタンがあり、クリックするとSQLサーバーに接続し、ストアドプロシージャを実行します。ボタンは正常に機能します(データをデータベーステーブルにプッシュするだけです)。
私は.NETプログラミングに不慣れで、すでに持っているボタンの現在のコードに追加する適切なコードのアイデアを見つけるのに苦労しています。
理想的には、ボタンがクリックされたときにメッセージボックスが表示され、「OK」オプションだけで「データが保存されました」ことをユーザーに通知し、ユーザーがホームページにリダイレクトされるようにします。
また、ユーザーがボタンを複数回押してほしくないので、このボタンが1回だけ押されるか、その日に一度押されると非アクティブになるようにする必要があります。
ボタンの現在のコードは次のとおりです。
Protected Sub btnAddRawData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddRawData.Click
'database conn, this is linked to the web config file .AppSettings
Using dbconnection As New SqlConnection(ConfigurationManager.AppSettings("dbconnection"))
dbconnection.Open()
'command to state the stored procedure and the name of the stored procedure
Using dbcommand As SqlCommand = dbconnection.CreateCommand
With dbcommand
.CommandType = CommandType.StoredProcedure
.CommandText = "GasNominationsRawData_Insert"
'simply execute the query
dbcommand.ExecuteNonQuery()
'I need to add some code for the button here and...
'redirect to the main home page
Response.Redirect("~/default.aspx?")
End With
End Using
End Using
End Sub
任意のアイデアや提案をいただければ幸いです。
よろしく、ベティ。