F
Fayven Wren
Can anyone assist a newb with troubleshooting the code below? I can
not seem to create new database records. I do not get any error
messages, just no new records. Editing and deleting works fine. I am
using VS 2005. If anyone can suggest a different, more active group
or web site I may be able to use in the future, I would appreciate it.
<%@ Page Language="VB" %>
<%@ import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SQLClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub DetailsView1_ItemInserted(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
Response.Redirect("LOV.aspx")
End Sub
Protected Sub DetailsView1_ModeChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewModeEventArgs)
If e.CancelingEdit = True Then
Response.Redirect("LOV.aspx")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Details View Insert</title>
</head>
<body>
<form id="form1" runat="server">
<aspetailsView DefaultMode="Insert" AutoGenerateRows="False"
DataKeyNames="Counter"
DataSourceID="SqlDataSource3" HeaderText="Insert LOV"
ID="DetailsView1" runat="server"
Width="275px" OnItemInserted="DetailsView1_ItemInserted"
OnModeChanging="DetailsView1_ModeChanging">
<Fields>
<asp:BoundField DataField="Counter" HeaderText="Counter"
ReadOnly="True" SortExpression="Counter" />
<asp:BoundField DataField="Code" HeaderText="Code"
SortExpression="Code" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Type" HeaderText="Type"
SortExpression="Type" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</aspetailsView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStringsubsConnectionString %>"
SelectCommand="Select Counter, Code, Description, Type From
tlkpLOV Where Counter = @Counter"
InsertCommand="Insert Into tlkpLOV(Code, Description,
Dependant, Type) Values(@Code, @Description, 0, @Type)" >
<SelectParameters>
<asp:QueryStringParameter Name="Counter"
QueryStringField="Counter" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asparameter Name="Code" Type="String" />
<asparameter Name="Description" Type="String" />
<asparameter Name="Type" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
not seem to create new database records. I do not get any error
messages, just no new records. Editing and deleting works fine. I am
using VS 2005. If anyone can suggest a different, more active group
or web site I may be able to use in the future, I would appreciate it.
<%@ Page Language="VB" %>
<%@ import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SQLClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub DetailsView1_ItemInserted(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
Response.Redirect("LOV.aspx")
End Sub
Protected Sub DetailsView1_ModeChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewModeEventArgs)
If e.CancelingEdit = True Then
Response.Redirect("LOV.aspx")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Details View Insert</title>
</head>
<body>
<form id="form1" runat="server">
<aspetailsView DefaultMode="Insert" AutoGenerateRows="False"
DataKeyNames="Counter"
DataSourceID="SqlDataSource3" HeaderText="Insert LOV"
ID="DetailsView1" runat="server"
Width="275px" OnItemInserted="DetailsView1_ItemInserted"
OnModeChanging="DetailsView1_ModeChanging">
<Fields>
<asp:BoundField DataField="Counter" HeaderText="Counter"
ReadOnly="True" SortExpression="Counter" />
<asp:BoundField DataField="Code" HeaderText="Code"
SortExpression="Code" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Type" HeaderText="Type"
SortExpression="Type" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</aspetailsView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStringsubsConnectionString %>"
SelectCommand="Select Counter, Code, Description, Type From
tlkpLOV Where Counter = @Counter"
InsertCommand="Insert Into tlkpLOV(Code, Description,
Dependant, Type) Values(@Code, @Description, 0, @Type)" >
<SelectParameters>
<asp:QueryStringParameter Name="Counter"
QueryStringField="Counter" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asparameter Name="Code" Type="String" />
<asparameter Name="Description" Type="String" />
<asparameter Name="Type" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</form>
</body>
</html>