Update is a type and cannot be used as an expressionhttp://forums.asp.net/t/1528457.aspx/1?Update+is+a+type+and+cannot+be+used+as+an+expressionWed, 24 Feb 2010 15:13:29 -050015284573694045http://forums.asp.net/p/1528457/3694045.aspx/1?Update+is+a+type+and+cannot+be+used+as+an+expressionUpdate is a type and cannot be used as an expression <p>'Update' is a type and cannot be used as an expression.&nbsp;<br> &nbsp;I've searched the forums and lowercased letters with no success.</p> <p>Here is my code:</p> <pre class="prettyprint">Dim SupplierContactNum As String = dataList1.DataKeys(e.Item.ItemIndex).ToString Dim SupplierContact As TextBox = CType(e.Item.FindControl(&quot;EditSupplierContactTB&quot;), TextBox) Dim TitlePosition As TextBox = CType(e.Item.FindControl(&quot;EditPositionTB&quot;), TextBox) Dim SupplierPhone As TextBox = CType(e.Item.FindControl(&quot;EditSupplierPhoneTB&quot;), TextBox) Dim CellPhone As TextBox = CType(e.Item.FindControl(&quot;EditCellTB&quot;), TextBox) Dim Address As TextBox = CType(e.Item.FindControl(&quot;EditAddressTB&quot;), TextBox) Dim Extension As TextBox = CType(e.Item.FindControl(&quot;EditExtensionTB&quot;), TextBox) Dim Email As TextBox = CType(e.Item.FindControl(&quot;EditEmailTB&quot;), TextBox) Dim Fax As TextBox = CType(e.Item.FindControl(&quot;EditSupplierFaxTB&quot;), TextBox) dataListSQL.UpdateParameters(&quot;SupplierContact&quot;).DefaultValue = SupplierContact.Text dataListSQL.UpdateParameters(&quot;Title&quot;).DefaultValue = TitlePosition.Text dataListSQL.UpdateParameters(&quot;SupplierPhone&quot;).DefaultValue = SupplierPhone.Text dataListSQL.UpdateParameters(&quot;CellPhone&quot;).DefaultValue = CellPhone.Text dataListSQL.UpdateParameters(&quot;Address&quot;).DefaultValue = Address.Text dataListSQL.UpdateParameters(&quot;Ext&quot;).DefaultValue = Extension.Text dataListSQL.UpdateParameters(&quot;EmailAddress&quot;).DefaultValue = Email.Text dataListSQL.UpdateParameters(&quot;SupplierFax&quot;).DefaultValue = Fax.Text dataListSQL.Update() dataList1.EditItemIndex = -1 dataList1.DataBind()</pre> <p>Thanks in advance.</p> 2010-02-22T17:24:03-05:003694244http://forums.asp.net/p/1528457/3694244.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>What type of object is dataListSQL?</p> <p>What type of object is dataList1?</p> <p>&nbsp;</p> 2010-02-22T19:23:10-05:003694280http://forums.asp.net/p/1528457/3694280.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>dataListSQL&nbsp;is a datasource</p> <p>dataList1 is a datalist</p> 2010-02-22T19:42:44-05:003694332http://forums.asp.net/p/1528457/3694332.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>&gt;&gt;&gt;dataListSQL&nbsp;is a datasource</p> <p>What kind of&nbsp;DataSource?</p> <p>(Sorry to stickle.)&nbsp;</p> 2010-02-22T20:12:50-05:003694343http://forums.asp.net/p/1528457/3694343.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>SQLDataSource ..&nbsp;I think that's what your asking... What I selected to create it in the toolbox?&nbsp;</p> 2010-02-22T20:17:52-05:003694368http://forums.asp.net/p/1528457/3694368.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>MCas --</p> <p>Hmm.</p> <p>There IS a parameterless&nbsp;Update method on the SqlDataSource-- that is a fact.</p> <p>I suggest that in this case one should try this refactor...</p> <p>Dim myReturn As Integer = dataListSQL.Update()&nbsp; </p> <p>...and see this link...</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.update.aspx">http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.update.aspx</a> </p> <p>...and check the code to be sure there is no object called &quot;Update&quot; anywhere...</p> <p>...and check to make sure the UpdateCommand is set...</p> <p>...and hopefully that will help.</p> <p>HTH.</p> <p>Thank you.</p> <p>-- Mark Kamoski</p> 2010-02-22T20:34:30-05:003694392http://forums.asp.net/p/1528457/3694392.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>What&nbsp;I don't understand though is that it just started happening since:</p> <p>-I changed the datakey</p> <p>-Added a field&nbsp;</p> <p>That's it.&nbsp; Anyways, I'm leaving work now. So if you reply, I won't reply until tomorrow at 8am. Thanks for your help. I'll test it tomorrow.</p> 2010-02-22T20:49:49-05:003696057http://forums.asp.net/p/1528457/3696057.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>I tried:</p> <p>Dim myReturn as integer = dataListSQL.Update() &nbsp;</p> <p>with no success.&nbsp; However, I'm not too sure what I'm supposed to do with myReturn afterwards.</p> 2010-02-23T13:29:10-05:003696205http://forums.asp.net/p/1528457/3696205.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>As it is,&nbsp;I would recommend making a very simplified sample.</p> <p>Then, once that is done, I would recommend posting both the complete code-infront and the code-behind here.</p> <p>Regarding this...</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>MCas86</h4> <p>I tried: </p> <p>Dim myReturn as integer = dataListSQL.Update() &nbsp;</p> <p></p> </blockquote> <p></p> <p>...what happended when you tried that? When you tried that that did you still get the same error &quot;Update is a type and cannot be used as an expression&quot;?</p> <p>Please advise.</p> <p>Thank you.</p> <p>-- Mark Kamoski</p> <p>&nbsp;</p> 2010-02-23T14:39:18-05:003696251http://forums.asp.net/p/1528457/3696251.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>When i tried the&nbsp;Dim&nbsp;myReturn ... </p> <p>i just dont know what to do after i make it equal to dataListSQL.Update(). I'm not getting a true error where it pops up and&nbsp;tells me... i added a watch and its just not firing i dont think.&nbsp;&nbsp;The error i listed is what my watch said.&nbsp;&nbsp;&nbsp;</p> 2010-02-23T15:03:47-05:003696417http://forums.asp.net/p/1528457/3696417.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p></p> <blockquote><span class="icon-blockquote"></span> <h4>MCas86</h4> <p>When i tried the&nbsp;Dim&nbsp;myReturn ... </p> <p>i just dont know what to do after i make it equal to dataListSQL.Update(). I'm not getting a true error where it pops up and&nbsp;tells me... i added a watch and its just not firing i dont think.&nbsp;&nbsp;The error i listed is what my watch said.&nbsp;&nbsp;&nbsp;</p> <p></p> </blockquote> &nbsp; <p></p> <p>You lost me there.</p> <p>Can you post a complete simplified version of your code that shows the problem?</p> <p></p> 2010-02-23T16:32:25-05:003696451http://forums.asp.net/p/1528457/3696451.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <pre class="prettyprint">Protected Sub DataList1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dataList1.UpdateCommand Dim SupplierContactNum As String = dataList1.DataKeys(e.Item.ItemIndex).ToString Dim SupplierContact As TextBox = CType(e.Item.FindControl(&quot;EditSupplierContactTB&quot;), TextBox) Dim TitlePosition As TextBox = CType(e.Item.FindControl(&quot;EditPositionTB&quot;), TextBox) Dim SupplierPhone As TextBox = CType(e.Item.FindControl(&quot;EditSupplierPhoneTB&quot;), TextBox) Dim CellPhone As TextBox = CType(e.Item.FindControl(&quot;EditCellTB&quot;), TextBox) Dim Address As TextBox = CType(e.Item.FindControl(&quot;EditAddressTB&quot;), TextBox) Dim Extension As TextBox = CType(e.Item.FindControl(&quot;EditExtensionTB&quot;), TextBox) Dim Email As TextBox = CType(e.Item.FindControl(&quot;EditEmailTB&quot;), TextBox) Dim Fax As TextBox = CType(e.Item.FindControl(&quot;EditSupplierFaxTB&quot;), TextBox) dataListSQL.UpdateParameters(&quot;SupplierContact&quot;).DefaultValue = SupplierContact.Text dataListSQL.UpdateParameters(&quot;Title&quot;).DefaultValue = TitlePosition.Text dataListSQL.UpdateParameters(&quot;SupplierPhone&quot;).DefaultValue = SupplierPhone.Text dataListSQL.UpdateParameters(&quot;CellPhone&quot;).DefaultValue = CellPhone.Text dataListSQL.UpdateParameters(&quot;Address&quot;).DefaultValue = Address.Text dataListSQL.UpdateParameters(&quot;Ext&quot;).DefaultValue = Extension.Text dataListSQL.UpdateParameters(&quot;EmailAddress&quot;).DefaultValue = Email.Text dataListSQL.UpdateParameters(&quot;SupplierFax&quot;).DefaultValue = Fax.Text '''''not firing''''' dataListSQL.Update() '''''''''''''''''''' dataList1.EditItemIndex = -1 dataList1.DataBind() End Sub</pre> <p><br> &nbsp;What&nbsp;I'm&nbsp;receiving when&nbsp;I &quot;Add Watch&quot; on Update is what the title of this thread is</p> 2010-02-23T16:49:51-05:003696465http://forums.asp.net/p/1528457/3696465.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>I tried to add a screenshot but it didnt work.</p> 2010-02-23T16:54:54-05:003696772http://forums.asp.net/p/1528457/3696772.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>Can you please&nbsp;post the source in the page behid that defines the '<strong>dataListSQL</strong>' control?&nbsp; It should be the code that begins with: </p> <pre class="prettyprint">&lt;asp:SqlDataSource id=&quot;dataListSQL&quot;</pre> <p><br> &nbsp;</p> 2010-02-23T20:49:12-05:003698012http://forums.asp.net/p/1528457/3698012.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <pre class="prettyprint">&lt;asp:SqlDataSource ID=&quot;dataListSQL&quot; runat=&quot;server&quot; ConnectionString=&quot;&lt;%$ ConnectionStrings:NCMRConnectionString3 %&gt;&quot; SelectCommand=&quot;SELECT SupplierContactNum, SupplierContact, Title, CellPhone, SupplierPhone, Address, Ext, EmailAddress, SupplierFax FROM [Supplier List] WHERE (Supplier = @SupplierDDL)&quot; UpdateCommand=&quot;UPDATE [Supplier List] SET SupplierContact=@SupplierContact, Title=@Title, SupplierPhone=@SupplierPhone, CellPhone=@CellPhone, Address=@Address, Ext=@Ext, EmailAddress=@EmailAddress, SupplierFax=@SupplierFax WHERE SupplierContactNum=@SupplierContactNum&quot; &gt; &lt;UpdateParameters&gt; &lt;asp:Parameter Name=&quot;Title&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;SupplierPhone&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;CellPhone&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;Address&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;Ext&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;EmailAddress&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;SupplierFax&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;SupplierContact&quot; Type=&quot;String&quot; /&gt; &lt;asp:Parameter Name=&quot;SupplierContactNum&quot; Type=&quot;Int32&quot; /&gt; &lt;/UpdateParameters&gt; &lt;SelectParameters&gt; &lt;asp:ControlParameter ControlID=&quot;DropDownList1&quot; Name=&quot;SupplierDDL&quot; PropertyName=&quot;SelectedValue&quot; /&gt; &lt;/SelectParameters&gt; &lt;/asp:SqlDataSource&gt;</pre> <p><br> &nbsp;</p> 2010-02-24T12:00:44-05:003698191http://forums.asp.net/p/1528457/3698191.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p></p> <blockquote><span class="icon-blockquote"></span> <h4>MCas86</h4> I'm not getting a true error where it pops up and&nbsp;tells me... i added a watch and its just not firing i dont think.&nbsp;&nbsp;The error i listed is what my watch said.&nbsp;&nbsp;&nbsp;</blockquote> <p></p> <p>So at this point you are receiving no error at all,&nbsp;and the code is executing completely but your Update is not being reflected in SQL Server correct?&nbsp; Have you checked SQL Server directly to see if the record actually was updated?&nbsp; </p> 2010-02-24T13:34:34-05:003698294http://forums.asp.net/p/1528457/3698294.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p>Correct. And yes&nbsp;I have.&nbsp;</p> 2010-02-24T14:23:32-05:003698391http://forums.asp.net/p/1528457/3698391.aspx/1?Re+Update+is+a+type+and+cannot+be+used+as+an+expressionRe: Update is a type and cannot be used as an expression <p></p> <blockquote><span class="icon-blockquote"></span> <h4>MCas86</h4> And yes&nbsp;I have.</blockquote> &nbsp; <p></p> <p>I am sorry.&nbsp; I see you checked it, but you did not state if it actually was updated.&nbsp; I am assuming it was not Updated and you were able to verify this?&nbsp; </p> <p>If the Update is not working, can you run the SQL manually using the parameters extracted by debugging the code and inserting them manually into the UPDATE statement, but run directly from SQL Server?&nbsp; At this point if you are not receiving a .NET exception, we need to see if the actual SQL has an issue.&nbsp; If you are fimilar with setting up a trace in SQL Server, you can also sniff out what SQL is actually being sent to the databse to see if it is 1. actually being sent, and 2. in the proper format.</p> 2010-02-24T15:13:29-05:00