R
Roel
Hi,
I'm currently investigating what new cool features ASP.NET 2.0 will bring.
When I use a GridView and a SQLDatasource like this:
<asp:gridview id="GridView" runat="server" font-size="8pt" backcolor="White"
allowpaging="True"
datasourceid="SqlDataSource" allowsorting="True" bordercolor="#999999"
borderstyle="None"
borderwidth="1px" cellpadding="3" gridlines="Vertical"
autogeneratecolumns="False">
<alternatingrowstyle backcolor="Gainsboro" font-italic="False"
font-bold="False">
</alternatingrowstyle>
<pagerstyle forecolor="Black" font-italic="False" font-bold="False"
horizontalalign="Center"
backcolor="#999999">
</pagerstyle>
<columnfields>
<asp:boundfield datafield="FIRSTNAME" headertext="Voornaam">
</asp:boundfield>
<asp:boundfield datafield="INSERTION" headertext="Tussenvoegsel">
</asp:boundfield>
<asp:boundfield datafield="LASTNAME" headertext="Achternaam">
</asp:boundfield>
<asp:commandfield edittext="Wijzigen" newtext="Nieuw"
showdeletebutton="True" showinsertbutton="True"
inserttext="Nieuw" deletetext="Verwijderen" canceltext="Annuleren"
showeditbutton="True">
</asp:commandfield>
</columnfields>
<summarytitlestyle borderwidth="1px" font-size="8pt" borderstyle="None"
bordercolor="#999999"
backcolor="White">
</summarytitlestyle>
<selectedrowstyle forecolor="White" backcolor="#008A8C"
font-italic="False" font-bold="True">
</selectedrowstyle>
<detailtitlestyle borderwidth="1px" font-size="8pt" borderstyle="None"
bordercolor="#999999"
backcolor="White">
</detailtitlestyle>
<rowstyle forecolor="Black" backcolor="#EEEEEE" font-italic="False"
font-bold="False">
</rowstyle>
<headerstyle forecolor="White" backcolor="#000084" font-italic="False"
font-bold="True">
</headerstyle>
<footerstyle forecolor="Black" backcolor="#CCCCCC" font-italic="False"
font-bold="False">
</footerstyle>
</asp:gridview>
<asp:sqldatasource id="SqlDataSource" runat="server" selectcommand="SELECT *
FROM Customer"
providername="System.Data.OleDb"
connectionstring="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;User ID=user;Initial Catalog=Webcard;Data
Source=1234;Use Procedure for Prepare=1;Auto Translate=True;Packet
Size=4096;Workstation ID=1234;Use Encryption for Data=False;Tag with column
collation when possible=False"
updatecommand="UPDATE customer SET FIRSTNAME = ? , INSERTION = ? , LASTNAME
= ? " insertcommand="INSERT INTO customer( FIRSTNAME, INSERTION, LASTNAME )
VALUES( ?, ?, ? ) " deletecommand="DELETE FROM customer WHERE (CUSTOMERID =
?) ">
<updateparameters>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
</updateparameters>
<insertparameters>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
</insertparameters>
<deleteparameters>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
</deleteparameters>
</asp:sqldatasource>
I get an impressive error:
[OleDbException (0x80040e21): Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was done.]
[InvalidOperationException: Command parameter[3] '' is invalid.
Command parameter[4] '' is invalid.
Command parameter[5] '' is invalid.
]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult
hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARA
MS dbParams, Object& executeResult) +69
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
+131
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) +62
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) +109
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +46
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(IDbCommand
command, DataSourceOperation operation) +72
System.Web.UI.WebControls.SqlDataSourceView.Update(IDictionary
parameters, IDictionary values) +316
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32
rowIndex) +1132
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e) +841
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.Raise
PostBackEvent(String eventArgument) +160
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +134
System.Web.UI.Page.ProcessRequestMain() +3298
----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.2.30703.27; ASP.NET
Version:1.2.30703.27 when I want to update a row in the grid.
Any suggestions?
Thanx,
Roel
I'm currently investigating what new cool features ASP.NET 2.0 will bring.
When I use a GridView and a SQLDatasource like this:
<asp:gridview id="GridView" runat="server" font-size="8pt" backcolor="White"
allowpaging="True"
datasourceid="SqlDataSource" allowsorting="True" bordercolor="#999999"
borderstyle="None"
borderwidth="1px" cellpadding="3" gridlines="Vertical"
autogeneratecolumns="False">
<alternatingrowstyle backcolor="Gainsboro" font-italic="False"
font-bold="False">
</alternatingrowstyle>
<pagerstyle forecolor="Black" font-italic="False" font-bold="False"
horizontalalign="Center"
backcolor="#999999">
</pagerstyle>
<columnfields>
<asp:boundfield datafield="FIRSTNAME" headertext="Voornaam">
</asp:boundfield>
<asp:boundfield datafield="INSERTION" headertext="Tussenvoegsel">
</asp:boundfield>
<asp:boundfield datafield="LASTNAME" headertext="Achternaam">
</asp:boundfield>
<asp:commandfield edittext="Wijzigen" newtext="Nieuw"
showdeletebutton="True" showinsertbutton="True"
inserttext="Nieuw" deletetext="Verwijderen" canceltext="Annuleren"
showeditbutton="True">
</asp:commandfield>
</columnfields>
<summarytitlestyle borderwidth="1px" font-size="8pt" borderstyle="None"
bordercolor="#999999"
backcolor="White">
</summarytitlestyle>
<selectedrowstyle forecolor="White" backcolor="#008A8C"
font-italic="False" font-bold="True">
</selectedrowstyle>
<detailtitlestyle borderwidth="1px" font-size="8pt" borderstyle="None"
bordercolor="#999999"
backcolor="White">
</detailtitlestyle>
<rowstyle forecolor="Black" backcolor="#EEEEEE" font-italic="False"
font-bold="False">
</rowstyle>
<headerstyle forecolor="White" backcolor="#000084" font-italic="False"
font-bold="True">
</headerstyle>
<footerstyle forecolor="Black" backcolor="#CCCCCC" font-italic="False"
font-bold="False">
</footerstyle>
</asp:gridview>
<asp:sqldatasource id="SqlDataSource" runat="server" selectcommand="SELECT *
FROM Customer"
providername="System.Data.OleDb"
connectionstring="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;User ID=user;Initial Catalog=Webcard;Data
Source=1234;Use Procedure for Prepare=1;Auto Translate=True;Packet
Size=4096;Workstation ID=1234;Use Encryption for Data=False;Tag with column
collation when possible=False"
updatecommand="UPDATE customer SET FIRSTNAME = ? , INSERTION = ? , LASTNAME
= ? " insertcommand="INSERT INTO customer( FIRSTNAME, INSERTION, LASTNAME )
VALUES( ?, ?, ? ) " deletecommand="DELETE FROM customer WHERE (CUSTOMERID =
?) ">
<updateparameters>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
</updateparameters>
<insertparameters>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
</insertparameters>
<deleteparameters>
<asp:controlparameter name="?" treatemptystringasnull="False"
propertyname="SelectedValue"
type="Char" controlid="GridView">
</asp:controlparameter>
</deleteparameters>
</asp:sqldatasource>
I get an impressive error:
[OleDbException (0x80040e21): Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was done.]
[InvalidOperationException: Command parameter[3] '' is invalid.
Command parameter[4] '' is invalid.
Command parameter[5] '' is invalid.
]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult
hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARA
MS dbParams, Object& executeResult) +69
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
+131
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) +62
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) +109
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +46
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(IDbCommand
command, DataSourceOperation operation) +72
System.Web.UI.WebControls.SqlDataSourceView.Update(IDictionary
parameters, IDictionary values) +316
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32
rowIndex) +1132
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e) +841
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.Raise
PostBackEvent(String eventArgument) +160
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +134
System.Web.UI.Page.ProcessRequestMain() +3298
----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.2.30703.27; ASP.NET
Version:1.2.30703.27 when I want to update a row in the grid.
Any suggestions?
Thanx,
Roel