UPDATE/DELETE Bug In SqlDataSource - Will Microsoft Ever Fix This?
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 Complete Forum Thread with Replies
Related Forum Messages:
-
SqlDataSource: Insert, Update And Delete Not Available
-
My SQLDataSource Select/Update/Insert/Delete
-
SqlDataSource Not Allowing Insert, Update And Delete
-
SqlDataSource: Can't Gen INSERT/UPDATE/DELETE Statements; Using 2.0 Membership Aspnetdb
-
SqlDataSource Insert, Update Delete Options Are Dimmed In Configure DataSource Control
-
VS2005 - Using Detailsview To Update, Insert And Delete Rows From SQL 2005 Database. Delete And Insert Work But Update Does Not - No Errors Returned
-
Is There Any Way To Get The SqlDataSource Wizard To Use Non-Microsoft-specific Syntax?
-
Need Help With Sqldatasource (delete)
-
How To Create A Update Button To Update Two SqlDataSource Controls?
-
Help On Displaying Data From Sqldatasource As Microsoft SQL Server (SQLClient)
-
GridView && SqlDataSource Delete Problem
-
Runtime Sqldatasource Delete Command
-
Get @@rowcount Data From MSSQL Using SqlDataSource With Delete Command
- Program Files, Microsoft SQL Server, 90, Samples Directory, Can't Access Or Delete
- Microsoft UPDATE BUG When Only One Row?
-
Sqldatasource Update Problem
-
Sqldatasource Update() Method
-
SqlDataSource Won't Update Table
-
Two Update Commands For A SqlDataSource?
-
How To Update SqlDataSource Query
-
Need Help With SQLDataSource Update Parameter
-
OldValuesParameterFormatString SqlDataSource Update
-
Using XML As An Update Parameter In A SqlDataSource?
-
Update Not Working In An SQLDataSource
-
SqlDataSource Update Parameter
-
Help With UPDATE With SqlDataSource And A Repeater
-
SQLDataSource.Update Returning Negative Value
-
Help: Programmatically Update Data From An SQLDataSource (C#)
-
Error During SqlDataSource.Update() Instruction
-
SQLDataSource: Update 2 Tables With 1 UpdateCommand?
-
Can't Update A Record Using A DetailsView And SqlDataSource
-
SQLDataSource Update Using Parameters Not Working
-
How To Trigger The Update Command Of The SQLDataSource
-
How To Put New Data Into SqlDataSource Update With Concatenated Key?
- Install That Update From The Microsoft Corporation
-
Qestion About SQLDataSource, Gridview, And Update Panel
-
SqlDataSource Use Code Behind Variables In Update Command
-
SqlDataSource Update Doesn't Work When Using Parameter
-
Multiple Sql Staements In SqlDataSource's Update Command
-
GridView Update, With SqlDataSource UpdateCommand Set From Code-behind. (C#)
- Microsoft Management Console Nice Update!
- Is Microsoft Going To Include KB940287 In A Cumulative Update?
-
Setting SqlDataSource Update Command And Parameters Dynamically C#
-
Gridview Button For Calling Sqldatasource.update Fails
-
SqlDataSource.Update With Session Variable As Input Parameter
-
UPDATE Statement Syntax Help Required C# && SqlDataSource Control
-
Update Via SQLDataSource Fails For Record With A Null Value In One Column
- Delete And Update
- Update And Delete
- Unable To Install SQL Server 2K5 Express From Microsoft Update
SqlDataSource: Insert, Update And Delete Not Available
Hello Guys, I’m trying to create a sqlDataSource using the wizard, I can get the select statement, the here clause and the order by clause but when I click on the Advanced button the options to generate the insert, update and delete statements are not available. Does anyone know what am I doing wrong?
View Replies !
My SQLDataSource Select/Update/Insert/Delete
hi i have form view that retrieves a single row i dont want to use SQLDataSource default Select/Update/Insert/Delete buttons i am using Stored Procedures I want to have my own buttons, the select has parameters, how to retrieve data for that parameter?
View Replies !
SqlDataSource: Can't Gen INSERT/UPDATE/DELETE Statements; Using 2.0 Membership Aspnetdb
Hi,I'm new to ASP.NET and having a problem configuring the SqlDataSource control. I am using the standard ASP.NET 2.0 "aspnetdb" database to manage user accounts. The problem is this:When using the wizard to configure my SqlDataSource control, the option to auto-generate the Insert/Update/Delete SQL statements are grayed out. I've searched this forum and found that this can be a symptom of no primary keys in the tables. However, there are primary keys (UserId), which is the default schema as generated by asp.net (aspnet_regsql.exe). When I use the wizard, I make the following choices:How would you like to retrieve data from your database?-> Select "Specify columns from a table or view"-> Select the "vw_aspnet_MembershipUsers" view from the "Name:" drop-down list-> Select "UserId", "Email", "UserName" from "Columns:"After this, still no option to auto-generate I/U/D statements. Any thoughts on why this isn't working??? Thanks,Leah.
View Replies !
VS2005 - Using Detailsview To Update, Insert And Delete Rows From SQL 2005 Database. Delete And Insert Work But Update Does Not - No Errors Returned
Using VS 2005 DetailsView to insert, delete, and update rows in SQL 2005 database. insert and delete work but update does not. I recieve no errors and the detailsView comes back unchanged (as well as table row is unchanged). I am trying to use as little code behind as possible. However I do have ItemUpdating routines that seem to work (i.e Checking table for new login duplicates and encrypting passwords). The following is the source code generated by VS2005:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="frmDbRegionMgrNew.aspx.vb" Inherits="frmDbRegionMgrNew" Title="Region Manager DB Update" Theme="detailsVeiwTheme" %><%@ Import Namespace="System.Data" %><!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>Untitled Page</title> </head><body><form id="form1" runat="server"><div><asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Large" ForeColor="#004000"Style="z-index: 101; left: 14px; position: absolute; top: 10px" Width="199px">Data Base Maintenance </asp:Label><asp:HyperLink ID="HyperLink1" runat="server" BackColor="ActiveBorder" BorderColor="ActiveBorder"BorderStyle="Outset" Font-Bold="True" Font-Size="X-Small" ForeColor="#004000"Height="31px" NavigateUrl="DataBaseMaint.aspx" Style="z-index: 133; left: 524px;position: absolute; top: 7px" Width="96px">DB Main Menu</asp:HyperLink><br /><br /><br /><table style="width: 654px"><tr><td style="width: 120px"><asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="Large" ForeColor="#004000"Text="Regional Manager" Width="189px"></asp:Label></td><td style="width: 100px"></td><td style="width: 203px"></td></tr><tr><td style="width: 120px" valign="top"><asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="#004000"Style="z-index: 128; left: 2px; position: absolute; top: 115px" Width="128px">Select Greenhouse -></asp:Label></td><td style="width: 100px" valign="top"><asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"DataTextField="Name" DataValueField="GrnHseID"></asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MetrolinadataConnectionString %>"SelectCommand="SELECT [GrnHseID], [Name] FROM [Greenhouse]"></asp:SqlDataSource></td><td style="width: 203px"> <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"DataKeyNames="RegionMgrID" DataSourceID="SqlDataSource2" Height="50px" Width="125px"><Fields><asp:TemplateField HeaderText="RegionMgrID" InsertVisible="False" SortExpression="RegionMgrID"><EditItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Eval("RegionMgrID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Bind("RegionMgrID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="GrnHseID" SortExpression="GrnHseID"><EditItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Eval("GrnHseID") %>'></asp:Label></EditItemTemplate><InsertItemTemplate><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("GrnHseID") %>'></asp:TextBox></InsertItemTemplate><ItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Bind("GrnHseID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:BoundField DataField="DispLvl" HeaderText="DispLvl" SortExpression="DispLvl" /><asp:BoundField DataField="FName" HeaderText="FName" SortExpression="FName" /><asp:BoundField DataField="Minit" HeaderText="Minit" SortExpression="Minit" /><asp:BoundField DataField="LName" HeaderText="LName" SortExpression="LName" /><asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" /><asp:BoundField DataField="Ext" HeaderText="Ext" SortExpression="Ext" /><asp:BoundField DataField="Cell" HeaderText="Cell" SortExpression="Cell" /><asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" /><asp:BoundField DataField="Login" HeaderText="Login" SortExpression="Login" /><asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" /><asp:BoundField DataField="AccessLvl" HeaderText="AccessLvl" SortExpression="AccessLvl" /><asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" /></Fields></asp:DetailsView><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConflictDetection="CompareAllValues"ConnectionString="<%$ ConnectionStrings:MetrolinadataConnectionString %>" DeleteCommand="DELETE FROM [RegionMgr] WHERE [RegionMgrID] = @original_RegionMgrID AND [GrnHseID] = @original_GrnHseID AND [DispLvl] = @original_DispLvl AND [FName] = @original_FName AND [Minit] = @original_Minit AND [LName] = @original_LName AND [Phone] = @original_Phone AND [Ext] = @original_Ext AND [Cell] = @original_Cell AND = @original_Email AND [Login] = @original_Login AND [Password] = @original_Password AND [AccessLvl] = @original_AccessLvl"InsertCommand="INSERT INTO [RegionMgr] ([GrnHseID], [DispLvl], [FName], [Minit], [LName], [Phone], [Ext], [Cell], , [Login], [Password], [AccessLvl]) VALUES (@GrnHseID, @DispLvl, @FName, @Minit, @LName, @Phone, @Ext, @Cell, @Email, @Login, @Password, @AccessLvl)"OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [RegionMgr] WHERE ([GrnHseID] = @GrnHseID)"UpdateCommand="UPDATE [RegionMgr] SET [GrnHseID] = @GrnHseID, [DispLvl] = @DispLvl, [FName] = @FName, [Minit] = @Minit, [LName] = @LName, [Phone] = @Phone, [Ext] = @Ext, [Cell] = @Cell, = @Email, [Login] = @Login, [Password] = @Password, [AccessLvl] = @AccessLvl WHERE [RegionMgrID] = @original_RegionMgrID AND [GrnHseID] = @original_GrnHseID AND [DispLvl] = @original_DispLvl AND [FName] = @original_FName AND [Minit] = @original_Minit AND [LName] = @original_LName AND [Phone] = @original_Phone AND [Ext] = @original_Ext AND [Cell] = @original_Cell AND = @original_Email AND [Login] = @original_Login AND [Password] = @original_Password AND [AccessLvl] = @original_AccessLvl"><DeleteParameters><asp:Parameter Name="original_RegionMgrID" Type="Int32" /><asp:Parameter Name="original_GrnHseID" Type="Int32" /><asp:Parameter Name="original_DispLvl" Type="Int32" /><asp:Parameter Name="original_FName" Type="String" /><asp:Parameter Name="original_Minit" Type="String" /><asp:Parameter Name="original_LName" Type="String" /><asp:Parameter Name="original_Phone" Type="String" /><asp:Parameter Name="original_Ext" Type="String" /><asp:Parameter Name="original_Cell" Type="String" /><asp:Parameter Name="original_Email" Type="String" /><asp:Parameter Name="original_Login" Type="String" /><asp:Parameter Name="original_Password" Type="String" /><asp:Parameter Name="original_AccessLvl" Type="Int32" /></DeleteParameters><UpdateParameters><asp:Parameter Name="GrnHseID" Type="Int32" /><asp:Parameter Name="DispLvl" Type="Int32" /><asp:Parameter Name="FName" Type="String" /><asp:Parameter Name="Minit" Type="String" /><asp:Parameter Name="LName" Type="String" /><asp:Parameter Name="Phone" Type="String" /><asp:Parameter Name="Ext" Type="String" /><asp:Parameter Name="Cell" Type="String" /><asp:Parameter Name="Email" Type="String" /><asp:Parameter Name="Login" Type="String" /><asp:Parameter Name="Password" Type="String" /><asp:Parameter Name="AccessLvl" Type="Int32" /><asp:Parameter Name="original_RegionMgrID" Type="Int32" /><asp:Parameter Name="original_GrnHseID" Type="Int32" /><asp:Parameter Name="original_DispLvl" Type="Int32" /><asp:Parameter Name="original_FName" Type="String" /><asp:Parameter Name="original_Minit" Type="String" /><asp:Parameter Name="original_LName" Type="String" /><asp:Parameter Name="original_Phone" Type="String" /><asp:Parameter Name="original_Ext" Type="String" /><asp:Parameter Name="original_Cell" Type="String" /><asp:Parameter Name="original_Email" Type="String" /><asp:Parameter Name="original_Login" Type="String" /><asp:Parameter Name="original_Password" Type="String" /><asp:Parameter Name="original_AccessLvl" Type="Int32" /></UpdateParameters><SelectParameters><asp:ControlParameter ControlID="DropDownList1" Name="GrnHseID" PropertyName="SelectedValue"Type="Int32" /></SelectParameters><InsertParameters><asp:Parameter Name="GrnHseID" Type="Int32" /><asp:Parameter Name="DispLvl" Type="Int32" /><asp:Parameter Name="FName" Type="String" /><asp:Parameter Name="Minit" Type="String" /><asp:Parameter Name="LName" Type="String" /><asp:Parameter Name="Phone" Type="String" /><asp:Parameter Name="Ext" Type="String" /><asp:Parameter Name="Cell" Type="String" /><asp:Parameter Name="Email" Type="String" /><asp:Parameter Name="Login" Type="String" /><asp:Parameter Name="Password" Type="String" /><asp:Parameter Name="AccessLvl" Type="Int32" /></InsertParameters></asp:SqlDataSource> </td></tr><tr><td style="width: 120px"></td><td style="width: 100px"></td><td style="width: 203px"></td></tr></table></div></form></body></html>Appreciate any and all help!Dave
View Replies !
Is There Any Way To Get The SqlDataSource Wizard To Use Non-Microsoft-specific Syntax?
The MSDN documentation for the SqlDataSource control says that it can be used for any data source that has an ADO.NET Data Provider.When I use this control with a ProviderName of "System.Data.Odbc" or "System.Data.OleDb", the SQL that the control generates through the wizard has square brackets around column names and table names.This is SQL syntax that is specific to SQL Server and Microsoft Access. I am trying to use non-Microsoft databases that do not have a custom ADO.NET Data Provider; I want to use the general-purpose System.Data.Odbc and System.Data.OleDb data providers.Is there any way to get the SqlDataSource to stop enclosing column and table names in square brackets?I realize that I can just write my own SQL statements, but I need to find out if there is a way to use the SqlDataSource wizard with my database.Thanks,Chuck
View Replies !
Need Help With Sqldatasource (delete)
I have a sqldatasource that I have just inserted some rows into via the: sqldatasource.insertparameters("devicename").defaultvalue = "SERVERNAME" sqldatasource.insert() I now want to via a list of machines, delete certain ones from the sqldatasource above. I tried the following but it is failing.. any thoughts as to why? sqldatasource.selectparameters=("devicename").defaultvalue = "SERVERNAME" sqldatasource.select(datasourceselectarguments.empty) sqldatasource.deleteparameters("devicename").defaultvalue = "SERVERNAME" sqldatasource.delete() I may be going about this totally wrong, I'm a bit new to this... I just want to select the row from the table that = "SERVERNAME" and then delete it. I have enabled inserts/updates/deletes in my datasource... thanks Stan
View Replies !
How To Create A Update Button To Update Two SqlDataSource Controls?
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 Replies !
Help On Displaying Data From Sqldatasource As Microsoft SQL Server (SQLClient)
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NWHCConnectionString %>" SelectCommand="SELECT * FROM [AI_news]" OnSelecting="SqlDataSource1_Selecting"> </asp:SqlDataSource> This is my code, I have followed the wizard perfectly the way its supposed ot be, well not 100% perfectly. This is how its supposed to be. When using a XXXX.MDF file I could use the wizard and it works fine. I do not know why my above code won't work. I am connected to the database and can view code manually. but not on a aspx page. i am using master page, now trying to add this into default.aspx Any help will be appreciated. I am currently losing some hair.
View Replies !
GridView && SqlDataSource Delete Problem
Hi guys! I have a simple windows form where a gridview is being populated by a database. I have checked the ability to update, insert delete. And everything is fine but when i want to delete a row it throws an exeption. The exeptions says: "Must declare the scalar variable "@id"."I haven't changed the delete, update and insert commands. They are as fallowsDeleteCommand="DELETE FROM [recepti] WHERE [id] = @id"InsertCommand="INSERT INTO [recepti] ([ime], [recepta], [snimka], [snimka2], [tip]) VALUES (@ime, @recepta, @snimka, @snimka2, @tip)" SelectCommand="SELECT * FROM [recepti]"UpdateCommand="UPDATE [recepti] SET [ime] = @ime, [recepta] = @recepta, [snimka] = @snimka, [snimka2] = @snimka2, [tip] = @tip WHERE [id] = @id" The id column is auto generated, unique, also it's a primery key.So any idea where is the problem?
View Replies !
Runtime Sqldatasource Delete Command
i need to dyanamically generate my SQL commands so to do that i am generating sqldatasource commands programmatically rather declaratively. SELECT commands seems to work fine but DELETE isnt doing anything, here is my code: SqlDataSource sdsConsultant = new SqlDataSource(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { loadDataSet(); //it just loads dataset used by formview initializeSDS(); } } protected void initializeSDS() { string strConnection = ConfigurationManager.ConnectionStrings["myDB"].ToString(); sdsConsultant.ConnectionString = strConnection; //SELECT sdsConsultant.SelectCommand = "SELECT * FROM Consultants WHERE (id=@id)"; QueryStringParameter id = new QueryStringParameter("id", "id"); sdsConsultant.SelectParameters.Add(id); //DELETE sdsConsultant.DeleteCommand = "DELETE * FROM Consultants WHERE (id=@id2)"; QueryStringParameter id2 = new QueryStringParameter("id2", "id"); sdsConsultant.DeleteParameters.Add(id2); //UPDATE Page.Controls.Add(sdsConsultant); FormView1.DataSource = sdsConsultant; FormView1.DataBind(); } my formview control looks like: <asp:FormView DefaultMode="Edit" ID="FormView1" runat="server" DataKeyNames="id" OnItemDeleted="FormView1_ItemDeleted" OnItemDeleting="FormView1_ItemDeleting"> the DELETE doesnt execute and the OnItemDeleted event doesnt do anything either. am i doing something wrong here? plz help
View Replies !
Get @@rowcount Data From MSSQL Using SqlDataSource With Delete Command
HiI'm using a simple SqlDataSource to connect to a stored proc to delete a number of rows from different tables.In my SQL im using: DECLARE @table1Count int DELETE FROM Table1 WHERE id = @new_id SET @table1Count=@@rowcount SELECT @table1Count I'm then using an input box and linking it to the delete control parameter. Then on a button click event i'm running SqlDataSource1.Delete() which all works fine. But how do i get the @table1Count back into my aspx page? Thanks
View Replies !
Program Files, Microsoft SQL Server, 90, Samples Directory, Can't Access Or Delete
"You don't currently have permission to access this folder." Viewing the Security tab for the folder gives, "You do not have permission to view or edit this object's permission settings." First question is the obvious one, "Why would this folder have been given permissions such that even the computer administrator cannot access it?" Running 32-bit Vista Home Premium I am and always was the one and only user, the one and only administrator. UAC is off. I had to re-format my primary hard drive several weeks ago. Before the re-format I had been running with Program Files redirected to the 2nd drive. The reason I re-formatted was that doing this causes Windows Update issues I never could solve so I finally (after nearly a year) decided to wipe it all and start over. I left the Program Files intact on the 2nd drive and installed clean on the primary drive. So this 'copy' of my Program Files directory has no link to the currently running operating system, yet I still cannot delete it. I need to free up space on the 2nd drive and while this folder seems to contain no files, its existence prevents me from deleting the root folder Program Files; which is just plain annoying. Now I could re-format the 2nd drive, but it contains all of my 'data', music, pictures, etc. I would have to copy it all to the 1st drive (~125G), reformat, copy it all back, and then re-direct all my special folders (again). I'm hoping for a quick fix so I can avoid that option.
View Replies !
Microsoft UPDATE BUG When Only One Row?
The update statement is failing with Timeout expired when there is only one row to update, otherwise if there are multiple rows to update it does not update the first row but updates the rest!!!?? Update cm_event_notification Set processed = '3/29/01 10:41:01 AM' Where dn = '{2E738808-23B4-11D5-B49A-00508BD934F8}'
View Replies !
Sqldatasource Update Problem
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 Replies !
Sqldatasource Update() Method
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 Replies !
SqlDataSource Won't Update Table
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 Replies !
How To Update SqlDataSource Query
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 Replies !
Need Help With SQLDataSource Update Parameter
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 Replies !
OldValuesParameterFormatString SqlDataSource Update
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 Replies !
Using XML As An Update Parameter In A SqlDataSource?
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 Replies !
Update Not Working In An SQLDataSource
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 Replies !
SqlDataSource Update Parameter
Using two FormView components and a SqlDataSource.When the Save button is pressed on my 2nd FormView, the Update method of my SqlDataSource is fired,but the how can I use a parameter from FormView1 in the Update statement? Here is a small example: FormView1 has a DataKeyName called Product_Key and a EditTemplateColumn called Product_NameFormView2 has a DataKeyName called Interval_Key and a EditTemplateColumn called Interval_Name The Update SQL is soemthing like: Update myTable set Product = @ProductKey, Product_Name = @ProductName, Interval_Key = @Interval_Key, Interval_Name = @Interval_Name Using the Command and Parameter Editor I inform the SqlDataSource that the Product_Key and Interval_Key belong to FormView1 and FormView2 respectivly.When I hit Update on FormView2, the @Interval_Name is populated (since this belongs to the FormView where I hit Update) but the @Product_Name is NULL. If I assign this a Source (FormView1) then the DataKeyName value is used. Can anyone help me out with this problem? Steven
View Replies !
Help With UPDATE With SqlDataSource And A Repeater
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 Replies !
Help: Programmatically Update Data From An SQLDataSource (C#)
ello all Would someone be so kind as to save me from getting balder through pulling my hair out. My aim is to extract data from a database using SQLDataSource, then edit the data and update the database using the SQLDataSource. I have achieve the problem of retrieving the data from the sqlDataSource:DataView openRemindingSeats = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty); //Int32 openRemindingSeats = SqlDataSource2.Select(DataSourceSelectArguments.Empty), DataView; foreach (DataRowView rowProduct in openReminding) { //Output the name and price lbl_NumOfSeatsLeft.Text = rowProduct["Remaining"].ToString(); } Within the sqlDataSource the sql code is as follows:SELECT [refNumber], [refRemaining] FROM [refFlights] WHERE ([refNumber] = @Number) So at the moment my problems is being able to edit and update data to the same SELECTed data.Thank you for any help that you might have... SynDrome
View Replies !
Error During SqlDataSource.Update() Instruction
Hi, I have such a problem:I try to update (or insert) a row in my table and i fail althought i,ve read many posts here. I.ve created a button and "on_click" event to this button and want that event to update or insert a record in my table. I wrote: protected void selectButton_Click(object sender, EventArgs e) { String taskID = projectsGridView.SelectedRow.Cells[0].Text; usersSqlDataSource.UpdateCommand = "update [Users] set [TaskID]=@task where [UserID]=1"; usersSqlDataSource.UpdateParameters.Add("task", taskID); usersSqlDataSource.Update(); } The application creates error in the last line of code (usersSqlDataSource.Update();) and i receive such an error:You have specified that your update command compares all values on SqlDataSource 'usersSqlDataSource', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges. For me it looks like there is a problem while setting parameters. Shall i change some properties of the sqlDataSource or GridView? Please help..
View Replies !
SQLDataSource: Update 2 Tables With 1 UpdateCommand?
I have a Gridview (edit enabled), connected to a SQLDataSource. SQLDataSource populates the gridview from 1 SelectCommand. figure1: ColumnA | ColumnB | ColumnC I have 2 SQL Server 2005 tables: Table1 and Table2 Now on my SQLDataSource's UpdateCommand, I want the value of ColumnB to go to Table1's ColumnB, and ColumnC to go to Table2's ColumnC. How do I do this? I understand I can't do this with 1 UPDATE-SET sql query. Maybe I can with stored procs or something, but im kinda noobish when it comes to this. How? Thanks
View Replies !
Can't Update A Record Using A DetailsView And SqlDataSource
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 Replies !
SQLDataSource Update Using Parameters Not Working
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 Replies !
How To Trigger The Update Command Of The SQLDataSource
Hi - I'm using .net2, and have a gridview, populated by a SQL Datasource (Edit, Insert, Delete, Select). Like we all used to do with the datagrid, I've added text boxes into the footer, and a link button, which I'd like to use to fire the Update command. How do I get the link button to trigger the update command? Thanks, Mark
View Replies !
How To Put New Data Into SqlDataSource Update With Concatenated Key?
Here is the problem. I have table such as this PK selection VARCHARPK selection_choice VARCHAR show BIT When I use the sqlDataSource to create an update it creates this.UPDATE lu_selection_choices SET show = @show WHERE (selection = @selection) AND (selection_choice = @selection_choice) Now this is OK, but when you perform an update and in say a details control you change the selection_choice the value of the parameter @selection_choice is going to be equal to the old data. So it performs a successful update on show which isn't being changed selection_choice is. So the questions is. Is there anyway to tell the update function of the datasource to insert the a new parameter with the SET selection_choice = @SOME NEW PARAM slection_choice? Thanks, Darren King
View Replies !
Qestion About SQLDataSource, Gridview, And Update Panel
I have a gridview that is tied to a SQLDataSource control which is inside an update panel. What I'm trying to accomplish is when the page is loaded the gridview is filled from the SQLDataSource. I have some textboxes also on the page so that the user can add new items to the gridview. The update panel trigger is tied to my code behind page through a button click which added the new data to the DB with an INSERT statement. Since the gridview was inside the update panel I thought when I placed the new data into the DB and the update panel caused the portion of the page that holds the gridview to refresh that the gridview would show the newly added data but it is not. I am missing something but I do not know what. I tried adding a gridview1.databind() and SQLDataSource1.DataBind() but niether caused the update of the gridview as I had hoped. Thanks for any of your help. Ty
View Replies !
SqlDataSource Update Doesn't Work When Using Parameter
Hi all: I have a list of items (actually a relation in which a user has selected an item, along with a rating for the item) in an Access database table, connected to my app with a SqlDataSource and bound to a repeater. The repeater displays the items to the user along with a dropdown box to show the rating, and allow the user to update it. The page connects and displays correctly. My problem is that when the user submits the page and I iterate through the repeater items to update each rating, the updates are not being completed in the database. The update works if I hard-code a value for the rating into the query itself, but not when using an updateparameter (pTaskRating below). In other words if I replace pTaskRating with '5', all the correct records will be found and have their ratings updated to 5. That means that the mySurveyId and pTaskId(DefaultValue) parameters have to be working, because the right records are found, but I can't seem to update records based on the DefaultValue of the pTaskRating parameter, even though I can verify that the DefaultValue is correct by placing a watch on it. It seems that my problem must be in my use of that particular parameter in the query, either in properties of the parameter or in the value assigned to it. I am extremely frustrated - any ideas would be greatly, greatly appreciated. Thanks! Bruck The table I'm pulling from and updating looks like this: SURVEY_ID (Text 50), TASK_ID (Long Int), RATING_ID (Long Int) Here's my ASPX for the main data source: <asp:SqlDataSource ID="sqlTaskSelections" runat="server" ConnectionString='Provider=Microsoft.Jet.OLEDB.4.0;Data Source="abc.mdb";Persist Security Info=True;Jet OLEDB:Database Password=xyz' ProviderName="System.Data.OleDb" SelectCommand="SELECT [SURVEY_ID], [TASK_ID], [RATING_ID] FROM [TBL_TASK_SELECTION] WHERE [SURVEY_ID] = mySurveyId" UpdateCommand="UPDATE [TBL_TASK_SELECTION] SET [RATING_ID] = pTaskRating WHERE ([SURVEY_ID] = mySurveyId) AND ([TASK_ID] = pTaskId)"> <UpdateParameters> <asp:SessionParameter Name="mySurveyId" SessionField="SurveyId" DefaultValue="" /><asp:Parameter Name="pTaskId" DefaultValue="" /><asp:Parameter Name="pTaskRating" DefaultValue="" /> </UpdateParameters> And here's the repeater (the Task ID and Rating are stored in hidden fields for easy access later): <asp:Repeater ID="rptTaskSelections" runat="server"> <HeaderTemplate><table border="0"></HeaderTemplate> <ItemTemplate> <tr class="abctr"><td class="normal"><asp:DropDownList ID="cbRatings" runat="server"></asp:DropDownList><asp:HiddenField ID="hTaskId" Runat="server" Visible="false" Value='<%# Eval("TASK_ID") %>' /><asp:HiddenField ID="hRating" Runat="server" Visible="false" Value='<%# Eval("RATING_ID") %>' /> <%# Eval("TASK_ID") %></td></tr> </ItemTemplate> <FooterTemplate></td></tr></table></FooterTemplate> </asp:Repeater> And here's the page load and submit VB: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then 'BIND / LOAD RATINGS TO DROPDOWN BOXES HEREDim i As IntegerDim cbCurrentRating As DropDownListDim hCurrentRating As HiddenFieldrptTaskSelections.DataSource = sqlTaskSelectionsrptTaskSelections.DataBind() For i = 0 To rptTaskSelections.Items.Count - 1 cbCurrentRating = rptTaskSelections.Items(i).FindControl("cbRatings")hCurrentRating = rptTaskSelections.Items(i).FindControl("hRating") cbCurrentRating.DataSource = sqlRatingscbCurrentRating.DataTextField = "RATING"cbCurrentRating.DataValueField = "ID"cbCurrentRating.DataBind()cbCurrentRating.SelectedValue = hCurrentRating.Value Next End If End Sub Protected Sub btnSubmitRateTasks_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmitRateTasks.Click 'UPDATE RATINGS HERE Dim i As IntegerDim cbCurrentRating As DropDownListDim hCurrentTaskId As HiddenField For i = 0 To rptTaskSelections.Items.Count - 1 cbCurrentRating = rptTaskSelections.Items(i).FindControl("cbRatings")hCurrentTaskId = rptTaskSelections.Items(i).FindControl("hTaskId") sqlTaskSelections.UpdateParameters.Item("pTaskId").DefaultValue = hCurrentTaskId.ValuesqlTaskSelections.UpdateParameters.Item("pTaskRating").DefaultValue = cbCurrentRating.SelectedValue sqlTaskSelections.Update() Next Response.Redirect("nextpage.aspx") End Sub
View Replies !
Multiple Sql Staements In SqlDataSource's Update Command
I have a gridview with a sqlDataSource with the SelectCommand as "SELECT Movie.Title, Movie.Category, Movie.ReleaseDate, ItemForSale.Quantity, ItemForSale.HasUnLimitedQuantity FROM ItemForSale INNER JOIN Movie ON ItemForSale.ID = Movie.ID" what kinda 'UpdateCommand' do I set so that ItemForSale is also updated from the grid? I tried two update statements seperated with a semicolon but that wouldn't work, any suggestions...
View Replies !
GridView Update, With SqlDataSource UpdateCommand Set From Code-behind. (C#)
Hi all I have a GridView on an aspx page, that is enabled for editing, deletion and sorting. In the Page_Load event of the aspx page, i add a SqlDataSource to the page, and bind the source to the GridView. When i click the update, or delete button, it makes a PostBack, but nothing is affected. I'm sure this has got something to do with the parameters. First, i tried having the GridView.AutoGenerateColumns set to True. I have also tried adding the columns manually, but no affect here either. The code for setting the commands, and adding the SqlDataSource to the page are as follows: string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; string strProvider = ConfigurationManager.ConnectionStrings["ConnectionString"].ProviderName; string selectCommand = "SELECT * FROM rammekategori"; SqlDataSource ds = new SqlDataSource(strProvider, strConn, selectCommand); ds.ID = "RammeKategoriDS"; ds.UpdateCommand = "UPDATE rammekategori SET Kategoribeskrivelse = @Kategoribeskrivelse WHERE (Kategorinavn = @Kategorinavn)"; ds.DeleteCommand = "DELETE FROM rammekategori WHERE (Kategorinavn = @Kategorinavn)"; Parameter Kategorinavn = new Parameter("Kategorinavn", TypeCode.String); Parameter Kategoribeskrivelse = new Parameter("Kategoribeskrivelse", TypeCode.String); ds.UpdateParameters.Add(Kategorinavn); ds.UpdateParameters.Add(Kategoribeskrivelse); ds.DeleteParameters.Add(Kategorinavn); Page.Controls.Add(ds); SqlDataSource m_SqlDataSource = Page.FindControl("RammeKategoriDS") as SqlDataSource; if (m_SqlDataSource != null) { this.gvRammeKategorier.DataSourceID = m_SqlDataSource.ID; } As mentioned - no affect at all! Thanks in advance - MartinHN
View Replies !
Microsoft Management Console Nice Update!
Hi, There is a tool you can install it to change the behavior of the Management Console, when you double-click on a table it will fire the Return All Rows command instead of the Properties command. I already saw this change but could not know where to get it from, any one of you know it? Thanks,
View Replies !
Is Microsoft Going To Include KB940287 In A Cumulative Update?
Re: KB 940287 - Will it be in a Cumulative Update? SYMPTOMS: You use Service Broker in SQL Server 2005. When the initiating service starts a conversation and then sends a message, the initiating service ends the conversation immediately. However, after the target service processes the message, the endpoint on the target server is not deleted when the target service ends the conversation. Therefore, when the initiating service starts a new conversation, the number of the conversation endpoints on the target server keeps increasing. Additionally, you receive the following error message on the initiator server: An error occurred while receiving data: '64(The specified network name is no longer available.)' This message could not be delivered because the conversation endpoint has already been closed. It has several workarounds. I've not been affected by this yet, but KB says it has a hotfix that has been out since July 2007, so it is curious that it has not been put into a Cumulative Update yet, at least as far as documentation in Knowledge Base is concerned. Does anyone know any more about this? Paul
View Replies !
Setting SqlDataSource Update Command And Parameters Dynamically C#
Hello all, Ok, I finally got my SqlDataSource working with Oracle once I found out what Oracle was looking for. My next hurdle is to try and set the Update Command and Parameters dynamically from a variable or radiobutton list. What I'm trying to accomplish is creating a hardware database for our computers by querying WMI and sending the info to textboxes for insertion and updating. I got that part all working nicely. Now I want to send the Computer name info to a different table column depending on if it is a laptop or desktop. I have been tossing around 2 ideas. A radiobutton list to select what it is and change the SQL parameters or do it by computer name since we have a unique identifier as the first letter ("W" for workstation, "L" for Laptop). I'm not sure what would be easiest but I'm still stuck on how this can be done. I posted this same question in here a few days ago, but I didn't have my SqlDataSources setup like I do now, I was using Dreamweaver 8, it is now ported to VS 2005. Below is my code, in bold is what I think needs to be changed dynamically, basically i need to change DESKTOP to LAPTOP...Thanks for all the help I've gotten from this forum already, I'm very new to ASP.NET and I couldn't do this without all the help. Thanks again! <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CAT %>"ProviderName="<%$ ConnectionStrings:CAT.ProviderName %>" SelectCommand='SELECT * FROM "COMPUTER"' UpdateCommand="UPDATE COMPUTER SET DESKTOP = :DESKTOP, TECH = :TECH, SERVICE_TAG = :SERVICE_TAG WHERE USERNAME=:USERNAME"> <UpdateParameters> <asp:ControlParameter Name="USERNAME" ControlId="txtUserName" PropertyName="Text"/> <asp:ControlParameter Name="SERVICE_TAG" ControlId="txtServiceTag" PropertyName="Text"/> <asp:ControlParameter Name="TECH" ControlId="txtTech" PropertyName="Text"/> <asp:ControlParameter Name="DESKTOP" ControlId="txtComputerName" PropertyName="Text"/> </UpdateParameters> </asp:SqlDataSource>
View Replies !
Gridview Button For Calling Sqldatasource.update Fails
<!-- Trying to create a GridView Survey form: Hi [User] Do you have these assets? [Gridview] Tag Number Response 123 [Yes ] [No] [Comments textbox] 234 [Yes ] [No] [Comments textbox] Goal: The desire is for the user to click Yes or No and have the database updated with the user's name, date, response and any comments. So far, I have created SqlDataSource with Select and Update commands, created the gridview and response buttons, setup the RowCommand and On_Updating Functions. Problems:1) If I call the update() function for SqlDataSource1 and misuse the Defaultvalue parameters to run the sql, no update is posted to the database. 2) If I use the On_Update function to set the parameter values, I get "Data type mismatch in criteria expression." (Additionally, the On_Update function runs twice which I don't understand)Can anyone tell me what/why? (and how to fix it?)Sorry for the deluge, but here is the code: --> <%@ Page Language="VB" %> <html> <head id="Head1" runat="server"> <title>Asset Survey</title> </head> <SCRIPT runat="server"> Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting e.Command.Parameters("Name1").Value = User.Identity.Name End Sub Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating 'For some reason, this function executes twice '2nd execution gets error: "Data type mismatch in criteria expression." 'e.Command.Parameters("PrimaryKey1").Value = intPrimaryKey 'e.Command.Parameters("Responder1").Value = strUser 'e.Command.Parameters("ResponseDate1").Value = dtModDate 'e.Command.Parameters("Response1").Value = strResponse 'e.Command.Parameters("ResponseComments1").Value = strComments End Sub Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) _ Handles GridView1.RowCommand Dim GridRow1 As Integer = Convert.ToInt32(e.CommandArgument) If e.CommandName = "UpdateYes" Then 'code here to disable buttons and textbox '... SqlDataSource1.UpdateParameters("Response1").DefaultValue = "Yes" End If If e.CommandName = "UpdateNo" Then 'code here to disable buttons and textbox '... SqlDataSource1.UpdateParameters("Response1").DefaultValue = "No" End If 'if I use the SqlDataSource1_Updating function, I get the mismatch error 'but if I (mis)use the DefaultValue parameter, no update occurs. SqlDataSource1.UpdateParameters("ResponseComments1").DefaultValue = _ GridView1.Rows(GridRow1).FindControl("txtComments").ToString SqlDataSource1.UpdateParameters("Responder1").DefaultValue = User.Identity.Name SqlDataSource1.UpdateParameters("ResponseDate1").DefaultValue = DateTime.Now SqlDataSource1.UpdateParameters("PrimaryKey1").DefaultValue = _ GridView1.Rows(GridRow1).Cells(0).Text Try SqlDataSource1.Update() 'Error Here if I use on_updating: "Data type mismatch in criteria expression." Catch except As Exception ' Handle the Exception. End Try End Sub </SCRIPT> <body> <form id="formInv" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LocalTestMDB %>" ProviderName="<%$ ConnectionStrings:LocalTestMDB.ProviderName %>" SelectCommand="SELECT [PrimaryKey], [Name], [AssetTag], [Response], [Responder], [ResponseDate],[ResponseComments] FROM [Tablename] WHERE ([Name] = ?) ORDER BY [Login Name], [AssetTag]" UpdateCommand="Update [Tablename] SET [Response]=@Response1, [Responder]=@Responder1, [ResponseDate]=ResponseDate1, [ResponseComments]=ResponseComments1 WHERE [PrimaryKey]=@PrimaryKey1" OnSelecting="SqlDataSource1_Selecting" OnUpdating="SqlDataSource1_Updating"> <SelectParameters> <asp:Parameter DefaultValue="" Name="Name1" Type=String /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="ResponseComments1" Type=String DefaultValue="" /> <asp:Parameter Name="Response1" Type=String DefaultValue="" /> <asp:Parameter Name="ResponseDate1" Type=DateTime DefaultValue="#8/1/2007 12:00:00PM#" /> <asp:Parameter Name="Responder1" Type=String DefaultValue="" /> <asp:Parameter Name="PrimaryKey1" Type=Int32 DefaultValue=0 /> </UpdateParameters> </asp:SqlDataSource> <span>Hi, Please respond by clicking "Yes" or "No" for each asset</span> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="PrimaryKey" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="PrimaryKey" HeaderText="PrimaryKey" AccessibleHeaderText="PrimaryKey" Visible=False/> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" AccessibleHeaderText="Name" /> <asp:BoundField DataField="AssetTag" HeaderText="AssetTag" SortExpression="AssetTag" AccessibleHeaderText="AssetTag" /> <asp:TemplateField HeaderText="Please Respond"> <ItemTemplate> <asp:Button ID="btnYes" runat="server" Text="Yes" Visible="true" CommandName='UpdateYes' CommandArgument='<%# CType(Container, GridViewRow).RowIndex %>' /> <asp:Button ID="btnNo" runat="server" Text="No" Visible="true" CommandName='UpdateNo' CommandArgument='<%# CType(Container, GridViewRow).RowIndex %>' /> <br /> <asp:Label ID="lblComments" runat="server" Text="Comments:" Visible=True></asp:Label> <asp:TextBox ID="txtComments" runat="server" Text='<%# Bind("ResponseComments") %>' Visible=True MaxLength=512 Height=24 Width=320 Wrap=True Enabled=True TextMode=MultiLine></asp:TextBox> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </form> </body> </html>
View Replies !
SqlDataSource.Update With Session Variable As Input Parameter
I'm getting a type mismatch error (currently string, when I think I need Int32 ?) with the code below. I'm having difficultly setting my session variable to type Int32 and having it take up the value of RawCoDeptRowID. When I "Watch" it, it's value remains as "snCoDeptRowID". Also, not sure if my Update command and it's snCoDeptRowID input parameter is well formed? Any advice would be greatly appreciated. Thank you. Web Page 1: Session["snCoDeptRowID"] = Convert.ToInt32 (RawCoDeptRowID); Web Page2:<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" UpdateCommand="UPDATE [CompanyDepartment] SET [User_Name] = @User_Name, [FirstName] = @FirstName, [LastName] = @LastName, [Company_Name] = @Company_Name, [Department_Name] = @Department_Name WHERE [User_ID] = @snCoDeptRowID "> <updateparameters> <asp:parameter Name="User_Name" Type="String" /> <asp:parameter Name="FirstName" Type="String" /> <asp:parameter Name="LastName" Type="String" /> <asp:Controlparameter Name="Company_Name" Type="String" ControlID ="ListBox1" PropertyName ="SelectedValue" /> <asp:Controlparameter Name="Department_Name" Type="String" ControlID ="ListBox2" PropertyName ="SelectedValue" /> <asp:QueryStringParameter Name="User_ID" Type="Int32" QueryStringField ="@snCoDeptRowID" DefaultValue ="@snCoDeptRowID" /> </updateparameters> </asp:SqlDataSource>
View Replies !
UPDATE Statement Syntax Help Required C# && SqlDataSource Control
Hi, I need to UPDATE the IP Address of a newly created user into a table (the value is currently set to default - " Not Available"), and I really dont know the syntax required to do this. So far I've derived all the variables needed using the following code: protected void ContinueButton_Click(object sender, EventArgs e) { //Get the ip address and put it into the customer table - (the instance of this user now exists) MembershipUser _membershipUser = Membership.GetUser(); Guid UserId = (Guid)_membershipUser.ProviderUserKey;<--------------------------------------------------------------I can see the UserId here if I pause the prog SqlDataSource customerDataSource = new SqlDataSource(); customerDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); customerDataSource.UpdateParameters.Add("IPAddress", Request.UserHostAddress.ToString());<---------------------------------------I can see the IPAddress here customerDataSource.UpdateCommandType = SqlDataSourceCommandType.Text; what next I've not got a clue as to what to write next. There is a try / catch statement after this using : rowsAffected = customerDataSource.Update(); which remains at 0 no matter what I try. Any help greatly appreciated.
View Replies !
Update Via SQLDataSource Fails For Record With A Null Value In One Column
Hi,I have an updatable DataGrid linked to a SQLDataSource in a web site developed using VS2005. Update works fine unless a value in the existing row is Null. Only one column in the database allows nulls.Putting a debug stop in the SqlDataSource1_Updating event, I checked the parameter value in the Immediate window and got the following result:?e.Command.Parameters(16){System.Data.SqlClient.SqlParameter}System.Data.SqlClient.SqlParameter: {System.Data.SqlClient.SqlParameter}DbType: Int32 {11}Direction: Input {1}IsNullable: FalseParameterName: "@original_FiresolveJobNo"Size: 0SourceColumn: ""SourceColumnNullMapping: FalseSourceVersion: Current {512}Value: NothingIs there a property I can set to generate a suitable Null check clause for the Update statement?Many Thanks,Keith.
View Replies !
Delete And Update
Hi All,I have a Access front-end,the tables are from SQL server 2000 andlinked via ODBC using DSN.I have a Main table and several related tables.The Main table has aOne -to- Many relationship with the related tables.When I try to delete a record from the front-end,I get a error msg "the table is locked,you and another user are attempting to delete/update the same record".I am the single user and I am at a loss tounderstand what the problem is.I have to explain that I never had a problem when i was using Accessas the backend too.Is it because of linking?Any suggestions?Roy
View Replies !
Update And Delete
I need to update rows in database A from data in database B and delete from database B if a match is found but leave in databse B if no match found. Is there a way do do this with the OLe DB command?
View Replies !
Unable To Install SQL Server 2K5 Express From Microsoft Update
Windows Update gave a 0X65B error when installing SQL Server 2K5 Express SP2. The solution said to copy the summary.txt data below to this forum: Time: 05/08/2007 11:06:22.102 KB Number: KB921896 Machine: WA10015USG93127 OS Version: Microsoft Windows XP Professional Service Pack 2 (Build 2600) Package Language: 1033 (ENU) Package Platform: x86 Package SP Level: 2 Package Version: 3042 Command-line parameters specified: /quiet /allinstances Cluster Installation: No ********************************************************************************** Prerequisites Check & Status SQLSupport: Passed ********************************************************************************** Products Detected Language Level Patch Level Platform Edition Express Database Services (SQLEXPRESS) ENU SP1 2005.090.2047.00 x86 EXPRESS Express Database Services (SQLExpress) ENU SP2 x86 EXPRESS ********************************************************************************** Products Disqualified & Reason Product Reason ********************************************************************************** Processes Locking Files Process Name Feature Type User Name PID ********************************************************************************** Product Installation Status Product : Express Database Services (SQLEXPRESS) Product Version (Previous): 2047 Product Version (Final) : Status : Failure Log File : C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGHotfixSQL9Express_Hotfix_KB921896_SQLEXPR.EXE SQL Express Features : SQL_Data_Files,SQL_Engine,SQL_SharedTools Error Number : 1627 Error Description : Unable to install Windows Installer MSI file ---------------------------------------------------------------------------------- Product : Express Database Services (SQLExpress) Product Version (Previous): Product Version (Final) : 3042 Status : Success Log File : C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGHotfixSQL9Express_Hotfix_KB921896_SQLEXPR.EXE SQL Express Features : Client_Components,Connectivity,SDK Error Number : 0 Error Description : ---------------------------------------------------------------------------------- ********************************************************************************** Summary One or more products failed to install, see above for details Exit Code Returned: 1627 Any help would be appreciated in getting this service pack installed. Thanks, Marty
View Replies !
|