vb.net と asp (visual studio 2008) Web サイトを使用して、SQL データベース内の単一のテーブルで動作する単純な Gridview を作成しようとしています。すべてのステートメントを手動で作成しましたが、それらは自動的に生成されません (削除、挿入、更新)。挿入と更新は正常に機能し、データベースにコミットします。削除しようとすると、次のエラーが発生します。
「削除コマンドが SqlDataSource 'mydatasource' のすべての値を比較するように指定しましたが、値に渡されたディクショナリが空です。削除に有効なディクショナリを渡すか、モードを OverwriteChanges に変更してください。」
楽観的同時実行を有効にするとこれが修正されることについて読んでいますが、データソースに更新、削除、挿入ステートメントを自動生成させる場合以外に有効にする方法がわかりません。私はここでそれをしていません。このまったく同じコードが、私が取り組んでいる別のプロジェクトで機能するため、途方に暮れています。どんな助けでも大歓迎です。
******************************************ASP CODE***************************************************
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
namespace="System.Web.UI.WebControls" tagprefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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 id="Head1" runat="server">
<title> OnCall Schedule </title>
<style type="text/css">
#form1
{
height: 731px;
width: 1122px;
}
</style>
</head>
<body>
<form id="frmDefault" method="post" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server">
</asp:ToolkitScriptManager>
<div>
</div>
<asp:SqlDataSource ID="dsOncallGroup" runat="server"
ConnectionString="<%$ ConnectionStrings:DiscussSQLConnectionString %>"
SelectCommand="SELECT * FROM tblOnCall WHERE (tblOnCall.fldOnCallGroup = @fldOnCallGroup)
AND (tblOnCall.fldEndOnCall > GETDATE())
ORDER BY tblOnCall.fldOnCallGroup, tblOnCall.fldEndOnCall, tblOnCall.fldRank"
OldValuesParameterFormatString="original_{0}"
ConflictDetection="CompareAllValues"
DeleteCommand="DELETE FROM tblOnCall WHERE fldOCID = @fldOCID"
InsertCommand="INSERT INTO [tblOnCall] ([fldOnCallGroup], [fldStartOnCall], [fldEndOnCall], [fldRank],
[fldEmpName], [fldEmpWorkPhone],
[fldEmpHomePhone],[fldEmpHomeCellPhone],[fldEmpAltPhone],[fldOCPreferredContact])
VALUES (@fldOnCallGroup, @fldStartOnCall, @fldEndOnCall, @fldRank, @fldEmpName, @fldEmpWorkPhone, @fldEmpHomePhone,
@fldEmpHomeCellPhone, @fldEmpAltPhone, @fldOCPreferredContact)"
UpdateCommand="UPDATE [tblOnCall] SET [fldOnCallGroup] = @fldOnCallGroup, [fldStartOnCall] = @fldStartOnCall,
[fldEndOnCall] = @fldEndOnCall, [fldRank] = @fldRank, [fldEmpName] = @fldEmpName, [fldEmpWorkPhone] =
@fldEmpWorkPhone,
[fldEmpHomePhone] = @fldEmpHomePhone,[fldEmpHomeCellPhone] = @fldEmpHomeCellPhone,[fldEmpAltPhone] = @fldEmpAltPhone,
[fldOCPreferredContact] = @fldOCPreferredContact
WHERE [fldOCID] = @original_fldOCID">
<SelectParameters>
<asp:ControlParameter ControlID="cboOncallGroup" Name="fldOnCallGroup"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name= "original_fldOCID" Type="Int16" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="fldOnCallGroup" Type="String" ConvertEmptyStringToNull="false" />
<asp:Parameter Name="fldStartOnCall" DbType ="DateTime2" />
<asp:Parameter Name="fldEndOnCall" DbType ="DateTime2" />
<asp:Parameter Name= "fldRank" Type="Int16" />
<asp:Parameter Name= "fldEmpName" Type="String" />
<asp:Parameter Name= "fldEmpWorkPhone" Type="String" />
<asp:Parameter Name= "fldEmpHomePhone" Type="String" />
<asp:Parameter Name= "fldEmpHomeCellPhone" Type="String" />
<asp:Parameter Name= "fldEmpAltPhone" Type="String" />
<asp:Parameter Name= "fldOCPreferredContact" Type="String" />
<asp:Parameter Name="original_fldOnCallGroup" Type="String" ConvertEmptyStringToNull="false" />
<asp:Parameter Name="original_fldStartOnCall" DbType="DateTime2" />
<asp:Parameter Name="original_fldEndOnCall" DbType="DateTime2" />
<asp:Parameter Name= "original_fldRank" Type="Int16" />
<asp:Parameter Name= "original_fldEmpName" Type="String" />
<asp:Parameter Name= "original_fldEmpWorkPhone" Type="String" />
<asp:Parameter Name= "original_fldEmpHomePhone" Type="String" />
<asp:Parameter Name= "original_fldEmpHomeCellPhone" Type="String" />
<asp:Parameter Name= "original_fldEmpAltPhone" Type="String" />
<asp:Parameter Name= "original_fldOCPreferredContact" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="fldOnCallGroup" Type="String" />
<asp:Parameter DbType="DateTime2" Name="fldStartOnCall" />
<asp:Parameter DbType="DateTime2" Name="fldEndOnCall" />
<asp:Parameter Name="fldRank" Type="Int16" />
<asp:Parameter Name="fldEmpName" Type="String" />
<asp:Parameter Name="fldEmpWorkPhone" Type="String" />
<asp:Parameter Name="fldEmpHomePhone" Type="String" />
<asp:Parameter Name="fldEmpHomeCellPhone" Type="String" />
<asp:Parameter Name="fldEmpAltPhone" Type="String" />
<asp:Parameter Name="fldOCPreferredContact" Type="String" />
<asp:Parameter Name="original_fldOnCallGroup" Type="String" ConvertEmptyStringToNull="false" />
<asp:Parameter Name="original_fldStartOnCall" DbType="DateTime2" />
<asp:Parameter Name="original_fldEndOnCall" DbType="DateTime2" />
<asp:Parameter Name= "original_fldRank" Type="Int16" />
<asp:Parameter Name= "original_fldEmpName" Type="String" />
<asp:Parameter Name= "original_fldEmpWorkPhone" Type="String" />
<asp:Parameter Name= "original_fldEmpHomePhone" Type="String" />
<asp:Parameter Name= "original_fldEmpHomeCellPhone" Type="String" />
<asp:Parameter Name= "original_fldEmpAltPhone" Type="String" />
<asp:Parameter Name= "original_fldOCPreferredContact" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsListbox" runat="server"
ConnectionString="<%$ ConnectionStrings:DiscussSQLConnectionString %>"
SelectCommand="SELECT DISTINCT [fldOnCallGroup] FROM [tblOnCall]">
</asp:SqlDataSource>
<br />
<div style="margin-left: 50px">
<asp:Image ID="Image1" runat="server" Height="100px"
ImageUrl="~/images/ITSLogo.jpg" Width="100px" />
<br /> <br /> <br /> <br />
<asp:DropDownList ID="cboOncallGroup" runat="server" DataSourceID="dsListbox" DataTextField="fldOnCallGroup"
DataValueField="fldOnCallGroup" AppendDataBoundItems="true"
OnSelectedIndexChanged="cboOnCallGroup_SelectedIndexChanged" AutoPostBack="true" Height="19px" Width="237px">
</asp:DropDownList>
</div>
<asp:SqlDataSource ID="dsEmp" runat="server"
ConnectionString="<%$ ConnectionStrings:DiscussSQLConnectionString %>"
SelectCommand="SELECT DISTINCT [fldEmpName] FROM [tblOnCall]">
</asp:SqlDataSource>
<br /> <br />
<div style="margin-left: 50px">
<asp:Gridview ID="gvOnCallSchedule" runat="server" AllowSorting="True" AllowPaging="True" showfooter="true"
OnRowUpdating="GvOnCall_Update" onRowCommand="gvOnCallSchedule_RowCommand" DataKeyNames="fldOCID"
BackColor="Aqua" DataSourceID="dsOncallGroup" Font-Bold="True"
Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" ForeColor="#333333" HorizontalAlign="Justify"
CellPadding="4" GridLines="None" PageSize="20" AutoGenerateColumns ="false"
OnSelectedIndexChanged="cboOnCallGroup_SelectedIndexChanged">
<Columns>
<asp:TemplateField ShowHeader="false">
<FooterTemplate>
<asp:ImageButton ID="AddButton" runat="server" CommandName="Insert" ImageURL="~/images/New.png"
Text="Add" ToolTip="Add New On Call Record" />
</FooterTemplate>
<EditItemTemplate>
<asp:ImageButton ID="UpdateButton" runat="server" CausesValidation="False" CommandName="Update"
ImageUrl="~/images/Save.png" Text="Update" ToolTip="Update" />
<asp:ImageButton ID="CancelButton" runat="server" CausesValidation="false" CommandName="Cancel"
ImageURL="~/images/Cancel.png" Text="Cancel" ToolTip="Cancel" />
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
ImageUrl="~/images/Edit.gif" Text="Edit" ToolTip="Edit" />
<asp:ImageButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
ImageUrl="~/images/Delete.png" Text="Delete" ToolTip="Delete" />
</ItemTemplate>
<ItemStyle Wrap="false" />
</asp:TemplateField>
<asp:Boundfield headertext="fldOCID" datafield="fldOCID" sortexpression="fldOCID" visible="false"
InsertVisible="False" />
<asp:TemplateField headertext="On Call Group">
<ItemTemplate>
<asp:DropDownList ID="ddlOCGroup" width="250px" runat="server" datavaluefield="fldOnCallGroup" Enabled="false"
DataSourceID= "dsListbox" SelectedValue="<%# Bind('fldOnCallGroup') %>">
</asp:DropDownList>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ftrddlOCGroup" width="250px" runat="server" datavaluefield="fldOnCallGroup"
DataSourceID= "dsListbox" SelectedValue="<%# Bind('fldOnCallGroup') %>">
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="Start Date/Time">
<ItemTemplate>
<asp:Textbox ID="txtStartOnCall" runat="server" Text='<%# Bind("fldStartOnCall") %>'>
</asp:Textbox>
<asp:Image ID="calpopup" runat="server" ImageUrl="~/images/calendar2.png" />
<asp:CalendarExtender ID="StartOnCallCal" runat="server" TargetControlID="txtStartOnCall"
PopupButtonID="calpopup" PopupPosition="Right" format="MM/dd/yyyy hh:mm:ss tt">
</asp:CalendarExtender>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox ID="txtStartOnCallFtr" runat="server" Text='<%# Bind("fldStartOncall") %>'>
</asp:Textbox>
<asp:Image ID="calpopupFtr" runat="server" ImageUrl="~/images/calendar2.png" />
<asp:CalendarExtender ID="StartOnCallCalFtr" runat="server" TargetControlID="txtStartOnCallFtr"
PopupButtonID="calpopupFtr" PopupPosition="Right" format="MM/dd/yyyy hh:mm:ss tt">
</asp:CalendarExtender>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="End Date/Time">
<ItemTemplate>
<asp:Textbox ID="txtEndOnCall" runat="server" Text='<%# Bind("fldEndOnCall") %>'>
</asp:Textbox>
<asp:Image ID="calpopup2" runat="server" ImageUrl="~/images/calendar2.png" />
<asp:CalendarExtender ID="EndOnCallCal" runat="server" TargetControlID="txtEndOnCall"
PopupButtonID="calpopup2" PopupPosition="Right" format="MM/dd/yyyy hh:mm:ss tt">
</asp:CalendarExtender>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox ID="txtEndOnCallFtr" runat="server" Text='<%# Bind("fldEndOnCall") %>'>
</asp:Textbox>
<asp:Image ID="calpopup2Ftr" runat="server" ImageUrl="~/images/calendar2.png" />
<asp:CalendarExtender ID="EndOnCallCalFtr" runat="server" TargetControlID="txtEndOnCallFtr"
PopupButtonID="calpopup2Ftr" PopupPosition="Right" format="MM/dd/yyyy hh:mm:ss tt">
</asp:CalendarExtender>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="Call Order">
<ItemTemplate>
<asp:Textbox ID="lblCallOrder" runat="server" Text='<%# Bind("fldRank") %>'>
</asp:Textbox>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox ID="txtCallOrderFtr" runat="server" Text='<%# Bind("fldOnCallGroup") %>'>
</asp:Textbox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="OnCall Analyst">
<ItemTemplate>
<asp:DropDownList ID="ddlAnalyst" runat="server" datavaluefield="fldEmpName"
datasourceID="dsEmp" SelectedValue='<%# Bind("fldEmpName") %>'>
</asp:DropDownList>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlAnalystFtr" runat="server" datavaluefield="fldEmpName"
DataSourceID= "dsEmp" SelectedValue='<%# Bind("fldEmpName") %>'>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="Work Phone">
<ItemTemplate>
<asp:Textbox ID="lblWorkPhone" runat="server" Text='<%# Bind("fldEmpWorkPhone") %>'>
</asp:Textbox>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox ID="txtWorkPhoneFtr" runat="server" Text='<%# Bind("fldEmpWorkPhone") %>'>
</asp:Textbox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="Home Phone">
<ItemTemplate>
<asp:Textbox ID="lblHomePhone" runat="server" Text='<%# Bind("fldEmpHomePhone") %>'>
</asp:Textbox>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox ID="txtHomePhoneFtr" runat="server" Text='<%# Bind("fldEmpHomePhone") %>'>
</asp:Textbox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="Personal Cell">
<ItemTemplate>
<asp:Textbox ID="lblHomeCellPhone" runat="server" Text='<%# Bind("fldEmpHomeCellPhone") %>'>
</asp:Textbox>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox ID="txtHomeCellPhoneFtr" runat="server" Text='<%# Bind("fldEmpHomeCellPhone") %>'>
</asp:Textbox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="Alternate Phone">
<ItemTemplate>
<asp:Textbox ID="lblAltPhone" runat="server" Text='<%# Bind("fldEmpAltPhone") %>'>
</asp:Textbox>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox ID="txtAltPhoneFtr" runat="server" Text='<%# Bind("fldEmpAltPhone") %>'>
</asp:Textbox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField headertext="Preferred Contact">
<ItemTemplate>
<asp:Textbox ID="lblOCPreferredContact" runat="server" Text='<%# Bind("fldOCPreferredContact") %>'>
</asp:Textbox>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox ID="txtOCPreferredContactFtr" runat="server" Text='<%# Bind("fldOCPreferredContact") %>'>
</asp:Textbox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" />
</asp:Gridview>
</div>
<br />
<br />
<div style="margin-left: 200px">
</div>
</form>
</body>
</html>
***************************************VB.net Code behind****************************************
Imports System
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Data.DataRowView
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub cboOnCallGroup_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles
cboOncallGroup.SelectedIndexChanged
'Dim cboAssignedFK As DropDownList = DirectCast(sender, DropDownList)
Dim cboOnCallGroup As String = TryCast(sender, DropDownList).SelectedValue
Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings
("DiscussSQLConnectionString").ConnectionString)
Dim sSql As System.Xml.Linq.XElement = <sql>
SELECT [fldOnCallGroup], [fldStartOnCall], [fldEndOnCall], [fldRank], [fldEmpName], [fldEmpWorkPhone],
[fldEmpHomePhone], [fldEmpHomeCellPhone], [fldEmpAltPhone], [fldOCPreferredContact]
FROM [tblOnCall]
WHERE ([fldOnCallGroup] = '<%= cboOnCallGroup %>')
ORDER BY [fldOnCallGroup], [fldEndOnCall], [fldRank] </sql>
Dim sqlCmd As New SqlCommand(sSql.Value, sqlConn)
Dim sqlRead As SqlDataReader
If sqlConn.State <> ConnectionState.Open Then
sqlConn.Open()
End If
sqlRead = sqlCmd.ExecuteReader()
sqlRead.Read()
sqlRead.Close()
sqlConn.Close()
End Sub
Function SendSQLCommand(ByVal tsSQLCmd As String, ByVal tsqlConn As SqlConnection) As Integer
Dim iRetVal As Integer = -1
Dim sqlCmd As New SqlCommand(tsSQLCmd, tsqlConn)
If tsqlConn.State <> ConnectionState.Open Then
tsqlConn.Open()
End If
Try
iRetVal = sqlCmd.ExecuteNonQuery()
Catch ex As Exception
Throw ex
End Try
Return iRetVal
End Function
Function SendSQLCommand2(ByVal tsSQLCmd As String, ByVal tsqlConn As SqlConnection) As Integer
Dim iRetVal As Integer = -1
Dim sqlCmd As New SqlCommand(tsSQLCmd, tsqlConn)
If tsqlConn.State <> ConnectionState.Open Then
tsqlConn.Open()
End If
Return iRetVal
End Function
Protected Sub GvOnCall_Update(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs)
Dim keyValue As Integer = e.Keys("fldOCID")
Dim strfldOnCallGroupOld As String = RTrim(LTrim(e.OldValues("fldOnCallGroup").ToString()))
Dim strfldOnCallGroupNew As String = RTrim(LTrim(e.NewValues("fldOnCallGroup").ToString()))
Dim strfldStartOnCallOld As String = RTrim(LTrim(e.OldValues("fldStartOnCall").ToString()))
Dim strfldStartOnCallNew As String = RTrim(LTrim(e.NewValues("fldStartOnCall").ToString()))
Dim strfldEndOnCallOld As String = RTrim(LTrim(e.OldValues("fldEndOnCall").ToString()))
Dim strfldEndOnCallNew As String = RTrim(LTrim(e.NewValues("fldEndOnCall").ToString()))
Dim strfldRankOld As Int32 = e.OldValues("fldRank")
Dim strfldRankNew As Int32 = e.NewValues("fldRank")
Dim strfldEmpNameOld As String = e.OldValues("fldEmpName")
Dim strfldEmpNameNew As String = e.NewValues("fldEmpName")
Dim strfldEmpWorkPhoneOld As String = e.OldValues("fldEmpWorkPhone")
Dim strfldEmpWorkPhoneNew As String = e.OldValues("fldEmpWorkPhone")
Dim strfldEmpHomePhoneOld As String = e.OldValues("fldEmpHomePhone")
Dim strfldEmpHomePhoneNew As String = e.OldValues("fldEmpHomePhone")
Dim strfldEmpHomeCellPhoneOld As String = e.OldValues("fldEmpHomeCellPhone")
Dim strfldEmpHomeCellPhoneNew As String = e.OldValues("fldEmpHomeCellPhone")
Dim strfldEmpAltPhoneOld As String = e.OldValues("fldEmpAltPhone")
Dim strfldEmpAltPhoneNew As String = e.OldValues("fldEmpAltPhone")
Dim strfldOnCallCellPhoneOld As String = e.OldValues("fldOnCallCellPhone")
Dim strfldOnCallCellPhoneNew As String = e.OldValues("fldOnCallCellPhone")
Dim fldOCPreferredContactOld As String = e.OldValues("fldOCPreferredContact")
Dim fldOCPreferredContactNew As String = e.OldValues("fldOCPreferredContact")
gvOnCall_Updated(keyValue, strfldOnCallGroupNew, strfldStartOnCallNew, strfldEndOnCallNew, strfldRankNew,
strfldEmpNameNew, _
strfldEmpWorkPhoneNew, strfldEmpHomePhoneNew, strfldEmpHomeCellPhoneNew, strfldEmpAltPhoneNew,
strfldOnCallCellPhoneNew, fldOCPreferredContactNew)
End Sub
Protected Sub gvOnCall_Updated(ByVal fldOCID As Integer, ByVal fldOnCallGroup As String, ByVal fldStartOnCall As
String, ByVal fldEndOnCall As String, _
ByVal fldRank As Integer, ByVal fldEmpName As String, ByVal fldEmpWorkPhone As String,
ByVal fldEmpHomePhone As String, _
ByVal fldEmpHomeCellPhone As String, ByVal fldEmpAltPhone As String, ByVal fldOnCallCellPhone As String,
ByVal fldOCPreferredContact As String)
Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings
("DiscussSQLConnectionString").ConnectionString)
Dim sSql As XElement
sSql = <sql>
Update [tblOncall] SET [fldOnCallGroup] = '<%= fldOnCallGroup %>',
[fldStartOnCall] = '<%= [fldStartOnCall] %>',[fldEndOnCall] = '<%= [fldEndOnCall] %>',
[fldRank] = '<%= [fldRank] %>', [fldEmpName] = '<%= [fldEmpName] %>', [fldEmpWorkPhone] = '<%= [fldEmpWorkPhone] %>',
[fldEmpHomePhone] = '<%= [fldEmpHomePhone] %>', [fldEmpHomeCellPhone] = '<%= [fldEmpHomeCellPhone] %>',
[fldEmpAltPhone] = '<%= [fldEmpAltPhone] %>', [fldOCPreferredContact] = '<%= [fldOCPreferredContact] %>'
Where [fldOCID] = '<%= [fldOCID] %>' </sql>
'MsgBox(Err.Description, MsgBoxStyle.Critical, "SQL Error")
SendSQLCommand(sSql.Value, sqlConn)
sqlConn.Close()
End Sub
Protected Sub gvOnCallSchedule_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.CommandEventArgs) Handles gvOnCallSchedule.RowCommand
If e.CommandName = "Insert" AndAlso Page.IsValid Then
Try
dsOncallGroup.Insert()
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "SQL Error")
'MsgBox("An error occured. Please ensure all required fields are entered and that the Application you
are trying to add doesn't already exist.", MsgBoxStyle.Critical, "Database Error")
Response.Redirect("Default.aspx")
End Try
Response.Redirect("Default.aspx")
End If
If e.CommandName = "Delete" Then
Try
dsOncallGroup.Delete()
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "SQL Error")
'MsgBox("Application Deleted Successfully")
End Try
Response.Redirect("Default.aspx")
End If
End Sub
Protected Sub dsOnCallGroup_Inserting(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs) Handles
dsOncallGroup.Inserting
Dim strddlGroupName As New DropDownList
Dim txtStartOnCall As New TextBox
Dim txtEndOnCall As New TextBox
Dim txtRank As New TextBox
Dim strddlEmpName As New DropDownList
Dim txtEmpWorkPhone As New TextBox
Dim txtEmpHomePhone As New TextBox
Dim txtEmpHomeCellPhone As New TextBox
Dim txtEmpAltPhone As New TextBox
Dim txtOCPreferredContact As New TextBox
strddlGroupName = CType(gvOnCallSchedule.FooterRow.FindControl("ftrddlOCGroup"), DropDownList)
txtStartOnCall = CType(gvOnCallSchedule.FooterRow.FindControl("txtStartOnCallFtr"), TextBox)
txtEndOnCall = CType(gvOnCallSchedule.FooterRow.FindControl("txtEndOnCallFtr"), TextBox)
txtRank = CType(gvOnCallSchedule.FooterRow.FindControl("txtCallOrderFtr"), TextBox)
strddlEmpName = CType(gvOnCallSchedule.FooterRow.FindControl("ddlAnalystFtr"), DropDownList)
txtEmpWorkPhone = CType(gvOnCallSchedule.FooterRow.FindControl("txtWorkPhoneFtr"), TextBox)
txtEmpHomePhone = CType(gvOnCallSchedule.FooterRow.FindControl("txtHomePhoneFtr"), TextBox)
txtEmpHomeCellPhone = CType(gvOnCallSchedule.FooterRow.FindControl("txtHomeCellPhoneFtr"), TextBox)
txtEmpAltPhone = CType(gvOnCallSchedule.FooterRow.FindControl("txtAltPhoneFtr"), TextBox)
txtOCPreferredContact = CType(gvOnCallSchedule.FooterRow.FindControl("txtOCPreferredContactFtr"), TextBox)
e.Command.Parameters("@fldOnCallGroup").Value = strddlGroupName.Text
e.Command.Parameters("@fldStartOnCall").Value = txtStartOnCall.Text
e.Command.Parameters("@fldEndOnCall").Value = txtEndOnCall.Text
e.Command.Parameters("@fldRank").Value = txtRank.Text
e.Command.Parameters("@fldEmpName").Value = strddlEmpName.Text
e.Command.Parameters("@fldEmpWorkPhone").Value = txtEmpWorkPhone.Text
e.Command.Parameters("@fldEmpHomePhone").Value = txtEmpHomePhone.Text
e.Command.Parameters("@fldEmpHomeCellPhone").Value = txtEmpHomeCellPhone.Text
e.Command.Parameters("@fldEmpAltPhone").Value = txtEmpAltPhone.Text
e.Command.Parameters("@fldOCPreferredContact").Value = txtOCPreferredContact.Text
'MsgBox(strddlGroup.Text, MsgBoxStyle.Information)
End Sub
End Class