Sqldatasource Update() Method

Apr 5, 2008

Hi All, 

i want to use sqldatasource with controlparameters.there are some textboxes and a dropdownlist on my page.i can easily insert and delete records on database table by using these controls as controlparameters by sqldatasource insert() and delete() method  but updating  fails.i use try catch block to see the error but no errors found.And also update() method returns 1 that indicates that it worked fine but when i look into the database i see that the record is not updated.i am stucked and surprised.any ideas please?

Thanks

 

View 5 Replies


ADVERTISEMENT

Update Method Is Not Finding A Nongeneric Method!!! Please Help

Jan 29, 2008

Hi,
 I just have a Dataset with my tables and thats it
 I have a grid view with several datas on it
no problem to get the data or insert but as soon as I try to delete or update some records the local machine through the same error
Unable to find nongeneric method...
I've try to create an Update query into my table adapters but still not working with this one
Also, try to remove the original_{0} and got the same error...
 Please help if anyone has a solution
 
Thanks

View 7 Replies View Related

SqlDataSource.SelectParameters Method

Apr 27, 2008

Hi,
 I am using a grid view with parameter defined in dropdown list. the asp code is:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Pubs %>"
SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE ([state] = @state)"
DeleteCommand="DELETE FROM [authors] WHERE [au_id] = @au_id">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="state" PropertyName="SelectedValue"
Type="String" /></SelectParameters>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Pubs %>"
SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE ([state] = @state)"
DeleteCommand="DELETE FROM [authors] WHERE [au_id] = @au_id">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="state" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</asp:SqlDataSource>
 I would like to to set the parameter assignment in my VB code in Page_Load methodWhen i am using:
SqlDataSource1.SelectParameters("state").DefaultValue = DropDownList1.Text
SqlDataSource1.SelectCommand = "SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE ([state] = @state)"I get error message saying: Object reference not set to an instance of an object.
Any ideas how I can set the select parameters (in my VB code) to use the dropdown list I have in my page?
Thanks,
 Uzi

View 8 Replies View Related

Use Select Method Of SqlDatasource

Dec 1, 2005

hiplz can any one tellHow should i use select method of SqlDatasourceplz show little code toothanks

View 1 Replies View Related

[ask] How To Invoke Sqldatasource Command In Method??

Apr 24, 2007

hello everybody, i have a question to ask, suppose i have a sqldatasource, can i use it in a method??this is my case, i need to make a new method to count the rows in a datagrid, so i will have to read the sqldatasource. the problem is, how to retrieve it?? usually i use the built in sqldatasource_selected to count the rows.... is there any other way?? 

View 6 Replies View Related

ASP Update Method Not Working After A MSDE To MSSQL 2005 Expess Update

Oct 20, 2006

The Folowing code is not working anymore. (500 error)

Set objRS = strSQL1.Execute
strSQL1 = "SELECT * FROM BannerRotor where BannerID=" & cstr(BannerID)
objRS.Open strSQL1, objConn , 2 , 3 , adCmdText
If not (objRS.BOF and objRS.EOF) Then
objRS.Fields("Exposures").Value =objRS.Fields("Exposures").Value + 1
objRS.update
End If
objRS.Close

The .execute Method works fine

strSQL1 = "UPDATE BannerRotor SET Exposures=Exposures+1 WHERE BannerID=" & cstr(BannerID)
objConn.Execute strSQL1

W2003 + IIS6.0

Pls advice?

View 1 Replies View Related

Inserting TextBox Values To Database Using SqlDataSource.Insert Method

Oct 25, 2006

Hi, it is few days I posted here my question, but received no answer. Maybe the problem is just my problem, maybe I put my question some strange way. OK, I try to put it again, more simply. I have few textboxes, their values I need to transport to database. I set SqlDataSource, parameters... and used SqlDataSource.Insert() method. I got NULL values in the database's record. So I tried find problem by using Microsoft's sample code from address http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.insert.aspx. After some changes I tried that code and everything went well, data were put into database. Next step was to separate code beside and structure of page to two separate files followed by new test. Good again, data were delivered to database. Next step: to use MasterPage, very simple, just with one ContentPlaceHolder. After this step the program stoped to deliver data to database and delivers only NULLs to new record. It is exactly the same problem which I have found in my application. The functionless code is here:http://forums.asp.net/thread/1437716.aspx I cannot find any answer this problem on forums worldwide. I cannot believe it is only my problem. I compared html code of two generated pages - with maserPage and without. There are differentions in code in ids' of input fields generated by NET.Framework:Without masterpage:<input name="NazevBox" type="text" id="NazevBox" /><span id="RequiredFieldValidator1" style='color:Red;visibility:hidden;'>Please enter a company name.</span><p><input name="CodeBox" type="text" id="CodeBox" /><span id="RequiredFieldValidator2" style='color:Red;visibility:hidden;'>Please enter a phone number.</span><p><input type="submit" name="Button1" value="Insert New Shipper" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="Button1" /> With masterpage:<input name="ctl00$Obsah$NazevBox" type="text" id="ctl00_Obsah_NazevBox" /><span id="ctl00_Obsah_RequiredFieldValidator1" style='color:Red;visibility:hidden;'>Please enter a company name.</span><p><input name="ctl00$Obsah$CodeBox" type="text" id="ctl00_Obsah_CodeBox" /><span id="ctl00_Obsah_RequiredFieldValidator2" style='color:Red;visibility:hidden;'>Please enter a phone number.</span><p><input type="submit" name="ctl00$Obsah$Button1" value="Insert New Shipper" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$Obsah$Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="ctl00_Obsah_Button1" />In second case ids' of input fields have different names, but I hope it is inner business of NET.Framework.There must be something I haven't noticed, maybe NET's bug, maybe my own. Thanks for any suggestion.

View 2 Replies View Related

UPDATE Method

Jun 29, 2006

I have a column of values in one table that needs to be updated based on an adjustment factor in another table. The table which contains the adjustment factors is built with the following column names.

RangeBeg RangeEnd Factor



The factor is determined depending on where the value falls in the range. I have been trying to do an sql script with no luck. Any Help would be appreciated.





Thanks

View 4 Replies View Related

How To Create A Update Button To Update Two SqlDataSource Controls?

May 10, 2006

I want to update two tables in one page. So I created two FormView bound on two SqlDataSource controls, and I create a Update button on the bottom of page. And I writen some codes as below:
btnUpate_Click(object sender, EventArgs e){
   sqlDataSource1.Update();
   sqlDateSource2.Update();}
But, the records haven't updated.
In SqlDataSource2_Updating() function, I found all the parameters is null.
So, how to modify my code to do it.
 
Zhang

View 2 Replies View Related

Update Method Not Working

Oct 27, 2004

UPDATE support, support_temp SET support.cat_id = support_temp.cat_id_new WHERE support.cat_id = support_temp.cat_id_old


Works with MySQL 4.0.20 but does not work with 3.23.58. What can i do to get that code to work with MySQL 3.23?

View 1 Replies View Related

UPDATE Method .WRITE

Oct 29, 2007

Hi, this SQL:

UPDATE [dbo].tblCommodity SET sImagePath .WRITE('abcdef', 0, 5)

gives me following error:
Cannot call methods on varchar.

I did it same way as it is in SQL Server Online Help :(

Thanks for ideas,
Martin

View 2 Replies View Related

Dataset Update Method Error?

Oct 26, 2007

I have a gridview and a dataset. When I start my application I see the results in my gridview. When I clic on edit and chanche some value and click on update it wil give me this error:ObjectDataSource 'ObjectDataSourcePersoon' could not find a non-generic method 'Update' that has parameters: naam, tussenvoegsel, achternaam, adres, woonplaats, telefoonnummer, original_id, Original_naam, Original_tussenvoegsel, Original_achternaam, Original_adres, Original_woonplaats, Original_telefoonnummer. Does someone know whats the problem??

View 10 Replies View Related

How To Use Inner Join In Update Method For 1 Table

Aug 23, 2007

i need to use inner join while updating..
im using only one table..


rajesh

View 2 Replies View Related

DataAdapter.Update Method Question.

Nov 30, 2006

Hi,

I am trying to use DataAdapter.Update to save a file stream into SQl Express.

I have a dialog box that lets user select the file:

openFileDialog1.ShowDialog();

I want to put

openFileDialog1.OpenFile();

Into

this.documentTableAdapter.Update(this.docControllerAlphaDBDataSet.Document.DocumentColumn);

I am thinking that it might just be some syntax issue, but I looked online, and didn't find much answers.

Thanks,
Ke

View 1 Replies View Related

Quick And Easy Question, Sql Update Method . . .

Nov 14, 2007

I am new to Sql, so I think this is a really easy question.
But I am working on a 2005 MSSQL database. 
When I add columns to an existing application with data and tables already being used, and the new column will be set to Database Null.
What is an easy way to quickly add the data to all the rows in the table.
For example if I am adding a checkbox, I've been doing it manually, add the column, change all the rows to False, one by one.
And then I can change it to Disallow DBNull.
As I get more and more users this could be a very time consuming process.
 
So the name of the Table is classifeds_Ads and let's say the column I want to add is Bonus and it needs to be filled with False.
How do I do this???
Thank you in advance
Daniel Meis
 

View 2 Replies View Related

How To Auto-increment Primary Key When Adding A New Row Using Update Method?

Jul 26, 2007

Hi guys,I followed the ASP.net official tutorial to create a DAL & Business Logic Layer (http://www.asp.net/learn/dataaccess/tutorial02cs.aspx). I have a table with a int ID field. I wish to write a function to add a new entry into this table but have the ID field auto-increment.The ID field is set as the Identity Column and has a Identity Increment & Seed of "1". If I manually go to the table and insert a new record leaving the ID value null it automatically increments. But if I create a C# function to add a new entry I get an error saying that the ID field can't be Null. Is there any way to use the Update method as shown on line 14 below to add a new entry but with it automatically incrementing? I did create a function called InsertDevice that simply inserts the other fields using a SQL INSERT and it auto-increments fine, just wondering if there is a way to do it using the DataTable and the Update method? Thanks for any help!!!  1 public bool AddDevice(string make, string model)
2 {
3 //cannot have the same device entered twice!
4 if (Adapter.FillDeviceCountByMakeModel(make, model) == 1)
5 return false;
6
7 RepositoryDataSet.DevicesDataTable devices = new RepositoryDataSet.DevicesDataTable();
8 RepositoryDataSet.DevicesRow device = devices.NewDevicesRow();
9
10 device.make = make;
11 device.model = model;
12
13 devices.AddDevicesRow(device); << Error thrown Here!
14 int rows_affected = Adapter.Update(devices);
15
16 return rows_affected == 1;
17 }
  

View 3 Replies View Related

VB6 Recordset Update Method Fails On SQL 2005 Server

Jan 13, 2008

Hi to all....

I'm new on this forum, but, I'm a experienced programmer.
I wanna solve this problem (if you can helpme....), recently, I'm trying to migrate an old SQL 7 to the new SQL 2005 server enterprise edition, I have no problem to import the data, users, stored procedures, etc. and all work fine, I can connect troght ODBC from the others computers, including some older pentium 1 mmx 200 mhz. with WIN98 (yes!).

My problem is an legacy VB6 application that work (well fine) with SQL7 server, but, when i change the odbc of the desktops systems to the new 2005 SQL server and run this legacy application hi recibe this error:
(english translation from spanish language)

[ODBC SQL Server Driver][SQL Server] The table to be modified is not included on this cursor or these can't be modified throught this cursor.

I have look on the source code of the legacy application, and someone of the segment's that causes error is:

------------------------------------------------------------------------


Public Function ConsultaCamara(sRutOP As String, _
sRut1 As String, _
strConsulta As String, _
Tipo As String, _
chk As CheckBox, _
Timer1 As Timer, _
LbAviso As Label) As Long
'----------------------------
Dim rsCACH, rsCACH_upd0, rsCACH_upd1, rsCACH_upd2 As ADODB.Recordset
Dim CmCACH As ADODB.Command
Dim lPendiente As Boolean
Dim lActivo As Boolean
Dim strSQL1, strSQL_upd0, strSQL_upd1, strSQL_upd2 As String
Dim StrWHE As String
Dim DameTiempo As Integer
Dim snombre As String
Dim sMsgEstado As String
Dim sAviso_Inicial As String
Dim cNum As String
Dim cDig As String
...
...
...
'Defino el string de consulta
strSQL1 = " SELECT RUTOPERADOR, " & _
" IDCAMARA, " & _
" RUTCONSULTADO, " & _
" ESTADO, " & _
" CANCON, " & _
" CADENACONSULTA, " & _
" FINGRESO, " & _
" FULCONSINT, " & _
" ULTRUTOP " & _
" FROM BOLETIN " & _
" WHERE RUTCONSULTADO = '" & sRut1 & "'" & _
" AND (ESTADO = 'PE' OR ESTADO = 'AC' )"

Set rsCACH = CreateObject("ADODB.Recordset")
rsCACH.ActiveConnection = cn
rsCACH.CursorType = adOpenKeyset
rsCACH.LockType = adLockOptimistic
rsCACH.Open strSQL1
If rsCACH.EOF Then 'No hay registro antiguo o en consulta, creo uno para consultar
sMsgEstado = "NO Existen datos ES REGISTRO NUEVO" & vbCr
rsCACH.AddNew
ConsultaCamara = GeneraID()
rsCACH.Fields("IDCAMARA") = ConsultaCamara
rsCACH.Fields("RUTOPERADOR") = sRutOP
rsCACH.Fields("RUTCONSULTADO") = sRut1
rsCACH.Fields("ESTADO") = "PE"
rsCACH.Fields("CANCON") = 1
rsCACH.Fields("CADENACONSULTA") = strConsulta
rsCACH.Fields("FINGRESO") = GetDateTime() 'Format(Date, "Short Date")
rsCACH.Fields("FULCONSINT") = GetDateTime() 'Format(Date, "Short Date")
rsCACH.Fields("ULTRUTOP") = sRutOP
rsCACH.Update <----- here's launches the error
...
...
...

--------------------------------------------------------

As you see, I'm not english spokeman, I hope that you understand me.

Thanks and best regards.

View 3 Replies View Related

Specified Method Is Not Supported Update Model Statistics Before Generating

Jun 15, 2007

I'm creating my first Report Model and I've managed to get through it, but if I select the "Update model statistics before generating" in the "Report Model Wizard", I get this error:



"Specified method is not supported"



(It would be a little less frustrating if it actually HAD specified the method <s>)



Anyone know what this is or how to fix it?



Thanks in advance,

Mike

View 3 Replies View Related

How To Create An Update Or Delete Method In A Strongly Typed Dataset?

Mar 22, 2007

Like the subject says, I'm using strongly typed datasets.  I'm using to designer to create the datasets and the methods.  I can select and insert, but I can't update or delete.  I right click on the adapter bar and select Add Query.   I sleect 'Use SQL Statements'I select 'Update' (or 'Delete')I get a sql statement pane containing the word 'Update' ('Delete') and asking 'What data should the table load?'I can click on next, but anything else gives me errors.  I'd list them, but I'm clearly doing something wrong and it's probably obvious. Diane 

View 5 Replies View Related

Any Easy Class Method To Update About 100 Fields Of A Database Using Stored Procedure?

Feb 1, 2007

Hi all,
 I am using  C# for ASP.NEt 2003.
I would like to know if there is any easy method to update a database with about 100 fields in it.
At present, I pass all the values of the controls on the web form to the stored procedure as parameters like :-
myCommand.Parameters.Add("@CustomerID", SqlDbType.Int).Value = txtCustomerID.text
Like this,  I add all 100 parameters.
Is there any easy method to do it using a class or any other methods?
Thanking you in advance,
Tomy

View 2 Replies View Related

Send Request To Stored Procedure From A Method And Receive The Resposne Back To The Method

May 10, 2007

Hi,I am trying to write a method which needs to call a stored procedure and then needs to get the response of the stored procedure back to the variable i declared in the method. private string GetFromCode(string strWebVersionFromCode, string strWebVersionString)    {      //call stored procedure  } strWebVersionFromCode = GetFromCode(strFromCode, "web_version"); // is the var which will store the response.how should I do this?Please assist.  

View 3 Replies View Related

Update Not Working In An SQLDataSource

Sep 6, 2006

I'm new to ASP and ASP.NET so I used the Wizards in Visual Web Deverlopment Express 2005 to build the following code:<asp:DetailsView ID="DetailsView" runat="server" DataSourceID="TracksDataSource"
Height="50px" Width="125px" AutoGenerateEditButton="True" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="pk_trackID" HeaderText="pk_trackID" ReadOnly="True" SortExpression="pk_trackID" />
<asp:BoundField DataField="trackName" HeaderText="trackName" SortExpression="trackName" />
<asp:BoundField DataField="trackPath" HeaderText="trackPath" SortExpression="trackPath" />
<asp:BoundField DataField="lyrics" HeaderText="lyrics" SortExpression="lyrics" />
</Fields>
</asp:DetailsView>

<asp:SqlDataSource ID="TracksDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
SelectCommand="SELECT * FROM [Tracks] WHERE ([pk_trackID] = @pk_trackID)" UpdateCommand="UPDATE [Tracks] SET [trackName] = @trackName, [trackPath] = @trackPath, [lyrics] = @lyrics WHERE [pk_trackID] = @pk_trackID" >
<UpdateParameters>
<asp:Parameter Name="trackName" Type="String" />
<asp:Parameter Name="trackPath" Type="String" />
<asp:Parameter Name="lyrics" Type="String" />
<asp:Parameter Name="pk_trackID" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="TracksListBox" Name="pk_trackID" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>  However, when I click Edit, change something, and then Update it doesn't update the database. However, if I remove the DataField bindings and use the AutoGenerateRows feature it works fine.

View 7 Replies View Related

Using XML As An Update Parameter In A SqlDataSource?

Nov 6, 2006

One of the requirements of the UpdateParameters for a GridView I'm building is that the fields that are being edited via EditItemTemplates are passed back to the UpdateParameter as XML. How would I go about combining the fields from the GridView/EditItems into an XML string that I can set as an asp:Parameter?
Thanks.

View 1 Replies View Related

OldValuesParameterFormatString SqlDataSource Update

Mar 15, 2007

OK guys, I'm sure I'm doing something stupid here but after 2 days I find myself extremely frusted... Any help would be appreciated
I'm tring to write an update procedure for an SqlDataSource control that will allow me to chage the primary key values of a record in the table. Everything seems to work fine with the exception of obtaining the old values (the primary key before its changed by the end user) during the update. I've read several articles on the web an in the forums on this topic. Much of it has to do with the .NET beta version alteration from "original_{0}" to "{0}". I believe those conversations do not describe my problem.
Anyhow, onto some source code. Here's the ASP source code for a grid view and sql data source. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="productName,productURL" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="productName" HeaderText="productName" ReadOnly="True"
SortExpression="productName" />
<asp:BoundField DataField="productURL" HeaderText="productURL" ReadOnly="True" SortExpression="productURL" />
<asp:BoundField DataField="productSupportURL" HeaderText="productSupportURL" SortExpression="productSupportURL" />
<asp:BoundField DataField="description" HeaderText="description" SortExpression="description" />
<asp:BoundField DataField="modified" HeaderText="modified" SortExpression="modified" />
<asp:BoundField DataField="userid" HeaderText="userid" SortExpression="userid" />
<asp:BoundField DataField="useridDomain" HeaderText="useridDomain" SortExpression="useridDomain" />
<asp:BoundField DataField="sortOrder" HeaderText="sortOrder" SortExpression="sortOrder" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SBAAdminConnectionString1 %>"
DeleteCommand="DELETE FROM [homePageList] WHERE [productName] = @old_productName AND [productURL] = @old_productURL"
InsertCommand="INSERT INTO [homePageList] ([productName], [productURL], [productSupportURL], [description], [modified], [userid], [useridDomain], [sortOrder]) VALUES (@productName, @productURL, @productSupportURL, @description, @modified, @userid, @useridDomain, @sortOrder)"
ProviderName="<%$ ConnectionStrings:SBAAdminConnectionString1.ProviderName %>"
SelectCommand="SELECT [productName], [productURL], [productSupportURL], [description], [modified], [userid], [useridDomain], [sortOrder] FROM [homePageList]"
UpdateCommand="UPDATE homePageList SET productSupportURL = @productSupportURL, description = @description, modified = @modified, userid = @userid, useridDomain = @useridDomain, sortOrder = @sortOrder, productName = @productName, productURL = @productURL WHERE (productName = @original_productName) AND (productURL = @original_productURL)" OldValuesParameterFormatString="original_{0}">
<DeleteParameters>
<asp:Parameter Name="old_productName" Type="String" />
<asp:Parameter Name="old_productURL" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="modified" Type="DateTime" />
<asp:Parameter Name="userid" Type="String" />
<asp:Parameter Name="useridDomain" Type="String" />
<asp:Parameter Name="sortOrder" Type="Single" />
<asp:Parameter Name="productName" Type="String" />
<asp:Parameter Name="productURL" Type="String" />
<asp:Parameter Name="productSupportURL" Type="String" />
<asp:ControlParameter ControlID="GridView1" Direction="InputOutput" Name="original_productName"
PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1" Direction="InputOutput" Name="original_productURL"
PropertyName="SelectedValue" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="productName" Type="String" />
<asp:Parameter Name="productURL" Type="String" />
<asp:Parameter Name="productSupportURL" Type="String" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="modified" Type="DateTime" />
<asp:Parameter Name="userid" Type="String" />
<asp:Parameter Name="useridDomain" Type="String" />
<asp:Parameter Name="sortOrder" Type="Single" />
</InsertParameters>
</asp:SqlDataSource>I added a text box for every field in the grid to the form and update the fields when the user selects a record in the GridView. I then added an Update button to the form and tied the event to this procedure:  Protected Sub bUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bUpdate.Click
'if the user has not entered key fields!
If missingKeyFields() Then
Exit Sub

End If

Dim count, so As Integer
Dim uDomain, uid As String

'parse out the user id and domain.
Try
If HttpContext.Current.User.Identity.Name = "" Then
uid = "unknow"
uDomain = "unknown"

Else
uid = HttpContext.Current.User.Identity.Name
uid = uid.Substring(uid.IndexOf("") + 1)
uDomain = uid.Substring(0, uid.IndexOf("") - 1)

End If

Catch ex As Exception
uid = "unknow"
uDomain = "unknown"

End Try

'fill in the parameters
'@productName, @productURL, @productSupportURL, @description, @modified, @userid, @useridDomain, @sortOrder
Me.SqlDataSource1.UpdateParameters.Item("productName").DefaultValue = Me.tbProductName.Text
Me.SqlDataSource1.UpdateParameters.Item("productURL").DefaultValue = Me.tbProductURL.Text
Me.SqlDataSource1.UpdateParameters.Item("productSupportURL").DefaultValue = Me.tbProductSupportURL.Text
Me.SqlDataSource1.UpdateParameters.Item("description").DefaultValue = Me.tbProductDescription.Text
Me.SqlDataSource1.UpdateParameters.Item("modified").DefaultValue = Now
Me.SqlDataSource1.UpdateParameters.Item("userid").DefaultValue = uid
Me.SqlDataSource1.UpdateParameters.Item("useridDomain").DefaultValue = uDomain
Me.SqlDataSource1.UpdateParameters.Item("sortOrder").ConvertEmptyStringToNull = True

If Integer.TryParse(Me.tbSortOrder.Text, so) Then
Me.SqlDataSource1.UpdateParameters.Item("sortOrder").DefaultValue = so

Else
Me.SqlDataSource1.UpdateParameters.Item("sortOrder").DefaultValue = ""

End If

'insert the record.
count = Me.SqlDataSource1.Update()
Me.lCommandInfo.Text = count.ToString + " record was updated."

End Sub
 The net result of the procedure is the message "0 record was updated." when I select a record in the gridView and then edit the "productName" field and click Update.
In an attempt to trace down the problem I added this code: Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating

Message.Text = e.Command.CommandText
Message.Text += "<br>"
For lp As Integer = 0 To e.Command.Parameters.Count - 1
Message.Text += e.Command.Parameters(lp).ParameterName + "=" + e.Command.Parameters(lp).Value
Message.Text += "<br>"

Next

End Sub
The message label displays the following text:UPDATE homePageList SET productSupportURL = @productSupportURL, description = @description, modified = @modified, userid = @userid, useridDomain = @useridDomain, sortOrder = @sortOrder, productName = @productName, productURL = @productURL WHERE (productName = @original_productName) AND (productURL = @original_productURL)
@description=interesting!
@modified=3/15/2007 4:07:31 PM
@userid=unknow
@useridDomain=unknown
@sortOrder=
@productName=ok22
@productURL=http
@productSupportURL=http
@original_productName=ok
@original_productURL=ok
Notice how the "@original_productURL" has the same value as the "@original_productName"? This should not be the case. The @original_productURL should equal "http" since I didn't update the field's value. It seems like the second field of the primary key is not getting updated or passed to the @original_productURL parameter. Since .NET handles the @original_{0} parameters I don't know why the field isn't being properly updated.
Any thoughts on how to track down the root cause of my problem... Or better yet any thoughts on a work around to my problem?
Thanks,Johnny

View 5 Replies View Related

Need Help With SQLDataSource Update Parameter

Jun 14, 2007

I need to know how to setup the ControlParameter for a template control in my Gridview? I have a datepicker in my template and I need to know how to refer to it in the ControlParameter of the SQLDataSource control.
  <UpdateParameters>
<asp:ControlParameter Name="dp_start" ControlID="bdpPlanStart" PropertyName="SelectedValue" Type="Datetime" />  Here is the template:<asp:TemplateField HeaderText="Start" SortExpression="dp_start">
<ItemTemplate>
<%#DataBinder.Eval(Container, "DataItem.dp_start", "{0:d}")%>
</ItemTemplate>
<EditItemTemplate>
<BDP:BasicDatePicker id="bdpPlanStart" SelectedValue='<%# DataBinder.Eval(Container.DataItem,"dp_start") %>' runat="server" DateFormat="d">
</BDP:BasicDatePicker>
</EditItemTemplate>
</asp:TemplateField>  

View 1 Replies View Related

How To Update SqlDataSource Query

Nov 7, 2007

I am trying to reload an AJAX control without reloading the page.  This question may belong under AJAX,  but I'm not sure if I'm managing the SqlDataSource correctly.  I want to set the SelectCommand to a new SQL statement and refresh the form on the screen.  My code is below.  It doesn't seem to be working.  Do I need to call something else or is this correct and the problem is with that nasty AJAX?SqlDataSource oSqlDataSource1 = (SqlDataSource) oContentPlaceHolder1.FindControl("SqlDataSource1");oSqlDataSource1.SelectCommand = "SELECT * FROM WorkHistory WHERE WorkHistoryID = " + sWorkHistoryID;oSqlDataSource1.Select(DataSourceSelectArguments.Empty);

View 2 Replies View Related

Two Update Commands For A SqlDataSource?

Jan 16, 2008

Is there a way to have two sql update commands so I can use both during an update depending on which row it is?

View 1 Replies View Related

SqlDataSource Won't Update Table

Feb 8, 2008

I have a number of textboxes in a WizardStep of my CreateUserWizard and I can't update the contents to the database (see below for an example). Any suggestions would be appreciated. Dim txt As TextBox = cuwMoreInfo.FindControl("txtAddress")
srcMoreInfo.UpdateParameters("Address").DefaultValue = DirectCast(txt, TextBox).Text 

View 12 Replies View Related

Sqldatasource Update Problem

Apr 18, 2008

I just want to update a single file on the table with the content of a text box

the sql statement is update GAMME set newvaleur=@newvaleur where product_ID=old_product_ID

on sqldatasource1 updating I wrote

E.COMMAND.PARAMETERS("@newvaleur").value=....
e.command.parameters("old_product_id").value=....

the thing is it doesn't work, I don't think the line with the old_product_id is ok but I don't know how to do it...

View 4 Replies View Related

Help With UPDATE With SqlDataSource And A Repeater

Jan 15, 2006

Hi,
I have a repeater which i need to build editing capabilities into in a similar way as the GridView, just a little unsure how to tie it together.  Ideally i would like to use a GridView as this would do all of the work for me however it looks like I need to go with the repeater due to the nested nature of the data I am working with.
What is the best way to go about updating the data source from within a repeater?  I have already built the edit interface with some MultiViews in the Repeater control and handling the ItemCommand event, just not sure how to actually update the data source.
Can I still use the SqlDataSource wizard to generate all of the SQL for me?  If so, within the ItemCommand event handler I have the data i want to update back to the database by using the FindControl method and retrieving the Text, but how do i get this data into the SqlDataSource object and update the database?
Are there any samples available which show how to update a datasource using a repeater?
Your help is much appreciated
trenyboy

View 6 Replies View Related

SQLDataSource Update Using Parameters Not Working

Jul 10, 2006

I'm passing a parameter to a stored procedure stored on my sqlserver, or trying to atleast.  And then firing off the update command that contains that parameter from a button.  But it's not changing my data on my server when I do so.
I'm filling a dropdown list from a stored procedure and I have a little loop run another sp that grabs what the selected value should be in the dropdown list when the page loads/refreshes.  All this works fine, just not sp that should update my data when I hit the submit button.
It's supposed to update one of my tables to whatever the selected value is from my drop down list.  But it doesn't even change anything.  It just refreshes the page and goes back to the original value for my drop down list.
Just to make sure that it's my update command that's failing, I've even changed the back end data manually to a different value and on page load it shows the proper selected item that I changed the data to, etc.  It just won't change the data from the page when I try to.
 
This is what the stored procedure looks like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALTER PROCEDURE [dbo].[UPDATE_sp] (@SelectedID int) AS
BEGIN
UPDATE [Current_tbl]
SET ID = @SelectedID
WHERE PrimID = '1'
END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And here's my aspx page:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Editor.aspx.vb" Inherits="Editor" %>
<!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 runat="server">
<title>Data Verification Editor</title>
</head>
<body>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SQLDS_Fill" runat="server" ConnectionString="<%$ ConnectionStrings:Test %>"
SelectCommand="Current_sp" SelectCommandType="StoredProcedure" DataSourceMode="DataSet">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SQLDS_Update" runat="server" ConnectionString="<%$ ConnectionStrings:Test %>"
SelectCommand="Validation_sp" SelectCommandType="StoredProcedure" DataSourceMode="DataReader"
UpdateCommand="UPDATE_sp" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:ControlParameter Name="SelectedID" ControlID="Ver_ddl" PropertyName="SelectedValue" Type="Int16" />
</UpdateParameters>
</asp:SqlDataSource>
<table style="width:320px; background-color:menu; border-right:menu thin ridge; border-top:menu thin ridge; border-left:menu thin ridge; border-bottom:menu thin ridge; left:3px; position:absolute; top:3px;">
<tr>
<td colspan="2" style="font-family:Tahoma; font-size:10pt;">
Please select one of the following:<br />
</td>
</tr>
<tr>
<td colspan="2">
<asp:DropDownList ID="Ver_ddl" runat="server" DataSourceID="SQLDS_Update" DataTextField="Title"
DataValueField="ID" style="width: 100%; height: 24px; background: gold">
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width:50%;">
<asp:Button ID="Submit_btn" runat="server" Text="Submit" Font-Bold="True"
Font-Size="8pt" Width="100%" />
</td>
<td style="width:50%;">
<asp:Button ID="Done_btn" runat="server" Text="Done" Font-Bold="True"
Font-Size="8pt" Width="100%" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label runat="server" ID="Saved_lbl" style="font-family:Tahoma; font-size:10pt;"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And here's my code behind:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Imports System.Data
Imports System.Data.SqlClient
Partial Class Editor
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Saved_lbl.Text = ""
Done_btn.Attributes.Add("OnClick", "window.location.href='Rpt.htm';return false;")
Dim View1 As New DataView
Dim args As New DataSourceSelectArguments
View1 = SQLDS_Fill.Select(args)
Dim Row As DataRow
For Each Row In View1.Table.Rows
Ver_ddl.SelectedValue = Row("ID")
Next Row
SQLDS_Fill.Dispose()
End Sub
Protected Sub Submit_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit_btn.Click
SQLDS_Update.Update()
Saved_lbl.Text = "Thank you. Your changes have been saved."
SQLDS_Update.Dispose()
End Sub
End Class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Any help is much appreciated.

View 4 Replies View Related

UPDATE/DELETE Bug In SqlDataSource - Will Microsoft Ever Fix This?

Aug 3, 2006

I'm referring to this bug, which I've seen a lot of people (including me) run into:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93937
Has anyone heard if MS plans to fix this soon?
Thanks

View 3 Replies View Related

Can't Update A Record Using A DetailsView And SqlDataSource

Feb 13, 2007

Hi,I'm trying to create a registration page that I've divided into multiple pages (first page for basic details, next page for address, etc.). I insert the record in the first page, and update it in the other pages. I pass the newly created ID to the other pages using the Page.PreviousPage property.  In the second page, I have the SqlDataSource configured as "SELECT * FROM [Table] WHERE ID = ?", and the UpdateCommand is "UPDATE .... WHERE ID = ?".  In Page_Load, I am updating the SelectCommand to "SELECT ... WHERE ID = " & intID, and the UpdateCommand similarly. The I do a dtlsvw.Databind()But when I go to the next page (the newly created ID is being passed properly), the update doesn't do anything. The new record doesn't contain the values in the detailsview. Can somebody help me out? Thanks,Wild Thing 

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved