On Formview Clicking Update Causes Form Data To Disappear?!?
Mar 24, 2008
Follow-up to:
http://forums.asp.net/t/1237676.aspx
The update command seems to be deleting my data. If I set the Parameter "DefaultValue" to "NULL" then it updates that field to the literal string: NULL
Hello, My company Intranet has a form that agents can use to post their comments about the company to upper management, but our customer service department would like to modify the form so that the agent has to pick from a comment type. The dropdown options on the form will be as follows: ComplimentsComplaintsGeneral CommentsSuggestions Each dropdown option has a designated table in a SQL DB.Using postback on the same page, I need to change which fields of the form are visible based upon which dropdown selection the user chooses, and I need the fields to then be inserted into the table that corresponds with the dropdown selection item. For example: If the Compliments dropdown selection is picked, I need a text box to show for the user's location, the name of the customer, account number, and the message box. Once the submit button is clicked, the characters in these boxes need to be inserted into the Compliments table using its data adapter. However, if the user selects Suggestions, the name of the customer and the account number should not be visible, since these fields do not exist and when the submit button is pressed, the Suggestions table should be updated. If you need more information, I will provide whatever is needed. As always, thanks for everyone's assistance. Chris
I have formview and I have a SqlDatasource for it.I have few textboxes in the edit mode and bind it to the data columns or fields in the database.If the data for all those fields have content in it, then it will update just fine. However, if one of the text field is null or empty, the formview can't be updated When i try to update with empty data in one textboxData field allows null value, and type are varchar.I am suspecting it's throwing an internal exception somewhere. However, since all the operations are handled by the asp.net. I have no idea what's going on internally. Does anyone have an idea what's causing this error and how to fix it?
Hi, I followed a msdn2 tutorial http://msdn2.microsoft.com/fr-fr/library/system.web.ui.webcontrols.formview(VS.80).aspx using a formview.I got one error when trying to update a field : System.Data.OracleClient.OracleException: ORA-01036: illegal variable name/numberHere is my DataBase definition :ColumnType Nullable Primary Key EMPLOYEE_IDNUMBER(6,0) No - 1 FIRST_NAMEVARCHAR2(20) Yes - - LAST_NAMEVARCHAR2(25) No - -If someone has already got this error before or see why it happen, i'll be very happy if he tell it to me why. Here is my aspx page code : <html xmlns="http://www.w3.org/1999/xhtml"><head><title>Titre Forview</title></head> <body> <form id="Form1" runat="server"> <h3>FormView Example</h3> <asp:FormView id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="false" datakeynames="Employee_ID" headertext="Employee Record" emptydatatext="No employees found." onitemupdating="EmployeeFormView_ItemUpdating" onmodechanging="EmployeeFormView_ModeChanging" runat="server"> <headerstyle backcolor="CornFlowerBlue" forecolor="White" font-size="14" horizontalalign="Center" wrap="false"/> <rowstyle backcolor="LightBlue" wrap="false"/> <pagerstyle backcolor="CornFlowerBlue"/> <itemtemplate> <table> <tr><td rowspan="6"></td> <td colspan="2"></td> </tr> <tr><td><b>Name:</b></td> <td><%# Eval("First_Name") %> <%# Eval("Last_Name") %></td> </tr> <tr><td><b>Employee_ID:</b></td> <td><%# Eval("Employee_ID") %></td> </tr> <tr><td><b>Hire Date:</b></td> <td><%# Eval("Hire_Date","{0:d}") %></td> </tr> <tr><td></td><td></td></tr> <tr><td colspan="2"> <asp:linkbutton id="Edit" text="Edit" commandname="Edit" runat="server"/></td> </tr> </table> </itemtemplate> <edititemtemplate> <table> <tr><td rowspan="6"></td> <td colspan="2"></td> </tr> <tr><td><b>Name:</b></td> <td><asp:textbox id="FirstNameUpdateTextBox" text='<%# Bind("First_Name") %>' runat="server"/> <asp:textbox id="LastNameUpdateTextBox" text='<%# Bind("Last_Name") %>' runat="server"/></td> </tr> <tr><td></td><td></td></tr> <tr><td><b>Hire Date:</b></td><td> <asp:textbox id="HireDateUpdateTextBox" text='<%# Bind("Hire_Date", "{0:d}") %>' runat="server"/> </td> </tr> <tr valign="top"><td></td><td></td></tr> <tr> <td colspan="2"> <asp:linkbutton id="UpdateButton" text="UPDATE" commandname="Update" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </edititemtemplate> </asp:FormView> <asp:label id="MessageLabel" forecolor="Red" runat="server"/> <asp:sqldatasource id="EmployeeSource" selectcommand="Select Employee_ID, Last_Name, First_Name, Hire_Date From Employees where EMPLOYEE_ID=99" updatecommand="update EMPLOYEES set LAST_NAME='Last_Name', FIRST_NAME='First_Name' where EMPLOYEE_ID=99" ConnectionString="<%$ ConnectionStrings:ConnectionStringOracle %>" ProviderName="<%$ ConnectionStrings:ConnectionStringOracle.ProviderName %>" runat="server"/> </form> </body></html> And my aspx.cs page code : using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Collections.Specialized;using System.Data.OracleClient;using System.Windows.Forms;public partial class A_Supprimer_Aussi : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } public void EmployeeFormView_ItemUpdating(Object sender, FormViewUpdateEventArgs e) { // Validate the field values entered by the user. This // example determines whether the user left any fields // empty. Use the NewValues property to access the new // values entered by the user. ArrayList emptyFieldList = ValidateFields(e.NewValues);
if (emptyFieldList.Count > 0) { // The user left some fields empty. Display an error message. // Use the Keys property to retrieve the key field value. String keyValue = e.Keys["EmployeeID"].ToString(); MessageLabel.Text = "You must enter a value for each field of record " + keyValue + ".<br/>The following fields are missing:<br/><br/>"; // Display the missing fields. foreach (String value in emptyFieldList) { // Use the OldValues property to access the original value // of a field. MessageLabel.Text += value + " - Original Value = " + e.OldValues[value].ToString() + "<br>"; } // Cancel the update operation. e.Cancel = true; } else { // The field values passed validation. Clear the // error message label. MessageLabel.Text = ""; } } ArrayList ValidateFields(IOrderedDictionary list) { // Create an ArrayList object to store the // names of any empty fields. ArrayList emptyFieldList = new ArrayList(); // Iterate though the field values entered by // the user and check for an empty field. Empty // fields contain a null value. foreach (DictionaryEntry entry in list) { if (entry.Value == String.Empty) { // Add the field name to the ArrayList object. emptyFieldList.Add(entry.Key.ToString()); } }
return emptyFieldList; } public void EmployeeFormView_ModeChanging(Object sender, FormViewModeEventArgs e) { if (e.CancelingEdit) { // The user canceled the update operation. // Clear the error message label. MessageLabel.Text = ""; } }}
Hi Folks, Somehow i am stuck at a very basic step. I have two pages - 1. DomainList.aspx which just displays all the records from the Domains table.2. DomainAddEdit.aspx which displays the selected record in FormView(Edit Mode) with two link for Update and Cancel. The Update link in the FormView does nothing on the first click. It just reloads the page with the new data I entered. If I click again on the Update link, it throws me an error: "Cannot insert the value NULL into column 'DNS', table 'MSInteractive.dbo.Domains'; column does not allow nulls. UPDATE fails.The statement has been terminated. " I have no clue why all this is happening. I have spent more than two days on this and this is very very frustrating. Just to mention, I haven't written any code for this. Its developed all using the VWD tools available. I have posted this message earlier but haven't got any response. I am sure most of you guys must have been doing these steps everyday. So, please post your thoughts. Thanks a million. Here is the relevant code for my DomainADDEdit.aspx: <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Edit"> <EditItemTemplate> Id: <asp:TextBox ID="IdTextBox" runat="server" Text='<%# Bind("Id") %>'></asp:TextBox><br /> RegistrarAccountId: <asp:TextBox ID="RegistrarAccountIdTextBox" runat="server" Text='<%# Bind("RegistrarAccountId") %>'></asp:TextBox><br /> Registrar: <asp:TextBox ID="RegistrarTextBox" runat="server" Text='<%# Bind("Registrar") %>'></asp:TextBox><br /> DNS: <asp:TextBox ID="DNSTextBox" runat="server" AutoPostBack="True" OnTextChanged="DNSTextBox_TextChanged" Text='<%# Bind("DNS") %>'></asp:TextBox><br /> EmailHost: <asp:TextBox ID="EmailHostTextBox" runat="server" Text='<%# Bind("EmailHost") %>'></asp:TextBox><br /> Registered: <asp:TextBox ID="RegisteredTextBox" runat="server" Text='<%# Bind("Registered") %>'></asp:TextBox><br /> Expires: <asp:TextBox ID="ExpiresTextBox" runat="server" Text='<%# Bind("Expires") %>'></asp:TextBox><br /> MsiResponsible: <asp:CheckBox ID="MsiResponsibleCheckBox" runat="server" Checked='<%# Bind("MsiResponsible") %>' /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MSInteractiveConnectionString %>" SelectCommand="SELECT [Id], [RegistrarAccountId], [Registrar], [DNS], [EmailHost], [Registered], [Expires], [MsiResponsible] FROM [Domains] WHERE ([Id] = @Id)" UpdateCommand="UPDATE Domains SET DNS = @txtDNS WHERE (Id = @Id)"> <UpdateParameters> <asp:FormParameter FormField="DNSTextBox" Name="txtDNS" /> <asp:QueryStringParameter Name="Id" QueryStringField="Id" /> </UpdateParameters> <SelectParameters> <asp:QueryStringParameter Name="Id" QueryStringField="Id" Type="String" /> </SelectParameters> </asp:SqlDataSource><br /> <asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" OnClick="UpdateButton_Click"></asp:LinkButton> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton> </EditItemTemplate>
I have a formview with name, email, and password. I bind all fields to sql except the password which is blank. In my sqldatasource, I define parameters for name, email and id: UpdateCommand="UPDATE UserProfile SET Name = @Name,Email = @Email WHERE (ID = @ID)"><UpdateParameters><asp:Parameter Name="Name" /><asp:Parameter Name="Email" /><asp:Parameter Name="ID" /></UpdateParameters> In code I want to add a password parameter if there is value in the password field otherwise I don't want the password field updated. If I add define a password parameter like above then if a user left the password field blank then their new is blank. That's way I think adding it dynamically is the way. But I am having problems with the code to add the parameter in sqldatasource_updating event. Protected Sub SqlProfile_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlProfile.UpdatingDim password As TextBox = FormView1.FindControl Protected Sub SqlProfile_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlProfile.Updating Dim password As TextBox = FormView1.FindControl("tb_password1") If Not password.Text.ToString & "" = "" Then SqlProfile.UpdateParameters.Add(New Parameter("@Password", TypeCode.String, password.Text.ToString)) End If
Greetings, I have setup a FormView which functions as it should but after the user input is updated, the table record stays unchanged, and when I trap the FormView1_ItemUpdated and look at the SqlDataSource1.UpdateCommand, it shows this: UPDATE [aspnet_test] SET first_name = '', last_name = '', email = '' WHERE id = @original_ID Here is most of the code I am using:<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="id, first_name, last_name" OnItemUpdating="FormView1_ItemUpdating" OnItemUpdated="FormView1_ItemUpdated" > .. // my ItemEditTempate is here.</asp:FormView> <EditItemTemplate>First Name: <asp:TextBox Text='<%# Bind("first_name") %>' runat="server" ID="author_name" Columns="20"></asp:TextBox><br />Last Name: <asp:TextBox Text='<%# Bind("last_name") %>' runat="server" ID="TextBox1" Columns="20"></asp:TextBox><br />E-mail: <asp:TextBox Text='<%# Bind("email") %>' runat="server" ID="TextBox2" Columns="20"></asp:TextBox><br /><br /><asp:Button ID="UpdateButton" runat="server" Text="Update" CommandName="Update" /><asp:Button ID="CancelButton" runat="server" Text="Cancel" CommandName="Cancel" /> </EditItemTemplate> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" SelectCommand="SELECT id, first_name, last_name, email FROM aspnet_test where id = 1"UpdateCommand="UPDATE [aspnet_test] SET first_name = '<%# first_name %>', last_name = '<%# last_name %>', email = '<%# email %>' WHERE id = @original_ID "> <UpdateParameters><asp:Parameter Name="original_ID" Type="Int32" /></UpdateParameters></asp:SqlDataSource> Any idea where the @original_ID is supposed to get its value from, or why does the SQL command shows blank fields?Thanks Eric.
Hello,What could possibly cause data in the SQL server database to beremoved, except being deleted manually? We had a couple of situationswhere data in certain records disappeared although the records werestill there. The data is entered and editted through the web interfacein ASP. The web interface is accessed by anyone who has an account inour database.I am more of a web programmer, not a SQL server administrator, so notvery familiar with SQL Server log or error tracking. If you cansuggest any way to track this kind of events (data disappearing), Iwould appreciate it very much.HB Kim
I install add-in and run fine for a while, then all of sudden I could not see Table Analyze tool and data mining tab at my ribbon. I re-run server configuration and re-connect to DMAddinDB (remote server, but I am the administrator), but data mining add-in and table analyzer still not showing at my ribbon.
Then I uninstall DMAddin, re-install it, go through configuration again, but still the tabs are not showing up.
My company is new to MDS. I am trying to set an attritube in an entity to read only so the users can't change the value in that field. When I did that, the whole model disappeared. I thought I had deleted it by accident so I created a test model and tried to do the same. The test model disappeared. This time, before saving the new settings I took a snapshot. After saving I took another snapshot. You can see that the whole model is gone (zz_RN_Permissions_Test). I tried every other coworker with admin rights and nobody shows it on the Models list. The behavior on the Excel add-in is correct. I can't change any values on that column. But I need to keep the models available.
I'm trying to create a online update form to a SQL table. I've neverdone this function before, and I'm not quite sure I have the codingcorrect. Below is the coding for the Update statement.final String udc = "UPDATE INTO " + "Comm_WebSubmission Set ProjectID= request.getParameter("ProjectID")(Assigned,DateAssigned,Status,StatusDescription,Re solution,CompletionDate)values(?,?,?,?,?,?)";Any help you can give me would be greatly appreciated.Cat
I'm very new to asp.net and c#, I have been thrown in the deep end with a project at work and I'm really struggling to overcome this problem so any help will be very greatly appreciated. I have a form with a number of textboxes that users use to update records in a database table with the use of a stored procedure. The problem is that I can't get the form to just update the boxes that a user has filled out. The form is working at the moment only if the user fills out all the boxes on the form which obviously is a waste of time if they only want to update one field. I have tested the stored procedure and it works fine. Please find the below code I'm trying to use! 1 protected void Targets_Insert(object sender, EventArgs e) 2 { 3 System.Data.SqlClient.SqlConnection objConn = new System.Data.SqlClient.SqlConnection(); 4 objConn.ConnectionString = "Data Source=SQL1;Password=rdbx;User ID=rdbx;Initial Catalog=Pronet"; 5 objConn.Open(); 6 System.Data.SqlClient.SqlCommand objCmd = new System.Data.SqlClient.SqlCommand("Update_Targets", objConn); 7 objCmd.CommandType = System.Data.CommandType.StoredProcedure; 8 9 System.Data.SqlClient.SqlParameter pdate = objCmd.Parameters.Add("@date", System.Data.SqlDbType.DateTime); 10 System.Data.SqlClient.SqlParameter pcontacts_new = objCmd.Parameters.Add("@contacts_new", System.Data.SqlDbType.Int); 11 System.Data.SqlClient.SqlParameter papplicants_new = objCmd.Parameters.Add("@applicants_new", System.Data.SqlDbType.Int); 12 System.Data.SqlClient.SqlParameter pclients_new = objCmd.Parameters.Add("@clients_new", System.Data.SqlDbType.Int); 13 System.Data.SqlClient.SqlParameter pHeadhunts_new = objCmd.Parameters.Add("@headhunts_new", System.Data.SqlDbType.Int); 14 System.Data.SqlClient.SqlParameter pCanvass_Calls_new = objCmd.Parameters.Add("@canvass_Calls_new", System.Data.SqlDbType.Int); 15 System.Data.SqlClient.SqlParameter pRegens_new = objCmd.Parameters.Add("@regens_new", System.Data.SqlDbType.Int); 16 System.Data.SqlClient.SqlParameter pJobs_Added_new = objCmd.Parameters.Add("@jobs_added_new", System.Data.SqlDbType.Int); 17 System.Data.SqlClient.SqlParameter pCVS_sent_new = objCmd.Parameters.Add("@CVS_sent_new", System.Data.SqlDbType.Int); 18 System.Data.SqlClient.SqlParameter puserid = objCmd.Parameters.Add("@userid", System.Data.SqlDbType.Int); 19 System.Data.SqlClient.SqlParameter punique_applicants_sent_new= objCmd.Parameters.Add("@unique_applicants_sent_new", System.Data.SqlDbType.Int); 20 System.Data.SqlClient.SqlParameter paverage_rate_new = objCmd.Parameters.Add("@average_rate_new", System.Data.SqlDbType.Int); 21 System.Data.SqlClient.SqlParameter paverage_salary_new = objCmd.Parameters.Add("@average_salary_new", System.Data.SqlDbType.Int); 22 System.Data.SqlClient.SqlParameter paverage_fee_new = objCmd.Parameters.Add("@average_fee_new", System.Data.SqlDbType.Int); 23 System.Data.SqlClient.SqlParameter pdeals_new = objCmd.Parameters.Add("@deals_new", System.Data.SqlDbType.Int); 24 System.Data.SqlClient.SqlParameter poffers_new = objCmd.Parameters.Add("@offers_new", System.Data.SqlDbType.Int); 25 System.Data.SqlClient.SqlParameter pinterviews_taken_place_new = objCmd.Parameters.Add("@interviews_taken_place_new", System.Data.SqlDbType.Int); 26 System.Data.SqlClient.SqlParameter pinterviews_arranged_new = objCmd.Parameters.Add("@interviews_arranged_new", System.Data.SqlDbType.Int); 27 System.Data.SqlClient.SqlParameter punique_mailshots_sent_new = objCmd.Parameters.Add("@unique_mailshots_sent_new", System.Data.SqlDbType.Int); 28 System.Data.SqlClient.SqlParameter pmailshots_new = objCmd.Parameters.Add("@mailshots_new", System.Data.SqlDbType.Int); 29 puserid.Value = Convert.ToInt16(userid.Text); 30 pdate.Value = Convert.ToDateTime(date.Text); 31 32 objCmd.ExecuteNonQuery(); 33 objConn.Close(); 34
I have a Table which stores data from two different databases. To update it I made a Web Form that opens a single record where you can edit the data (using TextBox). Then there is an Update Button, which is supoused to Update that record in the SQL Database. However, for some reason it does not work. I get no error and every thing seems to work fine, but the data is not updated. When running the same UPDATE statment in the SQL Query Analyzer everything works just fine. Here is the code for the button click (For test purpose I've set a spesific record to update the Task cell to "Test" and I've adde a DataGrid to be able to see if something is happening): Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim objConnection As SqlConnection Dim objDataAdapter As SqlDataAdapter Dim objDataSet As DataSet Dim objDataView As DataView Dim strConnect As String Dim strSQL As String Dim strUpdate As String strConnect = "Persist Security Info=False;Integrated Security=SSPI;server=SRV01;database=DB1" strSQL = "SELECT * FROM Users WHERE UserID ='" & Request.QueryString("UserID") & "'" strUpdate = "UPDATE Users SET Task = 'Test' WHERE UserID = 36" '" & Request.QueryString("UserID") & "'" objConnection = New SqlConnection(strConnect) objDataAdapter = New SqlDataAdapter(strSQL, objConnection) objDataAdapter.UpdateCommand = New SqlCommand(strUpdate) objDataSet = New DataSet objDataAdapter.Fill(objDataSet, "User") objDataView = New DataView(objDataSet.Tables("User")) dgrTest.DataSource = objDataView dgrTest.DataBind() objDataAdapter.ContinueUpdateOnError = True Try objDataAdapter.Update(objDataSet, "User") lblTest.Text = objDataAdapter.UpdateCommand.CommandText Catch ex As Exception lblTest.Text = "Error" End Try End Sub
Bear with me plase as I am nto very familiar with the coding world. The project I am working on is giving me troubles. I am trying to set up a form that can be used on line for our sales staff. It is a call activity form that I was hoping to submit to the DB I Have created in SQL. I would like the sales staff to fill out this form and then have their information transferred to the DB so that I can generate reports from that data. The trouble I am having is getting the intial connection to the DB opened up using the submit button on the form. I go into the code behind the page, and I have entered many scripts with no success. I continue to see that I receive erros when I try to use the opening line: Dim cn As New ADODB.Connection
If anyone out there has some sample scripting that would help me with this, I would really appreciate it. Thank you.
Question related to Visual Basic Video Lesson 09 (Databinding.wmv) by Bob Tabor.
Made a table and a UI form according to this lesson (table colums: CustomerID, FirstName, LastName).
Is it possible to use the same or an identical looking query form to find "Bob" by typing Bob in the Fist Name textbox or "Tabor" by typing Tabor in the Last Name textbox as in FileMaker?
I've a weird problem in my application. In of the pages, while trying to update the text box "Name", when I enter Linda's test, it gets saved as Linda''s test. I'm not sure if this is a problem due to SQL server. When I look at the stored procedure, I don't anything different. Also, when I update the table directly in SQL Server, the result is displayed in single quote. But if I update the field thro' the application, the returned name is with double quotes instead of single quote. Has any of you faced problems like this? What am I missing? What do I need to do to get the name saved the way I entered (with single quotes) instead of double quotes?
When I click on an error message in the messages/results screen, it no longer highlights the correct section of code to show where the error is - somehow it has gone out of sync and just highlights a random piece of code.
Does anyone know how to reset it so that the error in the messages screen matches up to the correct line of code?
HiI am using Visual Web Developer 2005 Express and SQL Server Express 2005.From Northwind I can display data to Gridview.Could someone point me in the right direction on two points.How do I start a new database (.mdf) - I cannot find this option.I can change Northwind around - but I want to start my own database. Once I have that sorted - how can I "insert" data into database using a dropdown box?A "dropdown" box such as you would find online. Thanks in advance.Stephen
My boss wants to know why I can sort information in the Enterprise Manager by clicking the column headings but he can't; like in the Job window clicking status to sort the jobs by status so all of the 'executing' jobs are listed first. I said no problem, let's apply SP2 and that should do the trick. To my chagrin it did not solve the problem. I would appreciate any ideas.
I've got a package that was imported from SQL 2000 into SQL 2005. I'm trying to edit it in Business Int. Dev Studio. When I open what used to be a data pump step in 2000, I'm able to edit items. However, when I click OK, it puts an error right below the buttons:
"" is not a value type
And it won't let me save my changes. I have no idea where this error is coming from. All the data pumps in this package cause the same error. Your help is appreciated.
I need help to resolve the following problem. I have a form that is supposed to insert data into my data base. But I get an error message when I click submit. Below is the Code and after that is the error message that I get. Thank you in advance.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) End SubProtected Sub insertSubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) SqlDataSource1.Insert()End Sub </script><html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function pageLoad() { }
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.] System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +2132728 System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +108 System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection) +55 System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +11 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +353 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1194
I'm trying to make a query to insert data form xls file to my database and it's working
Here's my code
INSERT INTO MY_TABLE SELECT SAP_NBR, PERIOD, ANSWER, OSAT, SCORE FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="C: ipTMP_Aubrygsi_osat.xls"; User ID=Admin;Password=;Extended properties=Excel 8.0')...Sheet1$ WHERE SAP_NBR is not null AND PERIOD is not null AND ANSWER is not null AND OSAT is not null AND SCORE is not null
And I would like to verify if there no sap_nrb and period already the same in the database so I add : AND SAP_NBR not in MY_TABLE.SAP_NBR AND PERIOD not in MY_TABLE.PERIOD
In SQL Server 2008 when I click the middle button I could scroll up and down(scroll wheel) by just flicking the mouse. We just upgraded to 2012 and I can't do that on my Lenovo ThinkPad. I am using an external wired usb mouse(Intelli Mouse) to scroll.
I have SQL server 2008 and 2012 installed on the same machine scrolling works in 2008 but not in 2012.
Hi, We have few reports which users want to export rather than see them on the web. Is there any way to directly export the report (in a specified format say .CSV) when user clicks on generate report. This way they don't have to wait till report is rendered on the web page and then export it.
When I select the database and right click. I receive the following error:
Cannot show requested dialog Additional Information:
Cannot show requested dialog (sqlMgmt)
Property Owner is not available for Database '[DB_name]'. This property may not exist for this object, or may not be retrievabledue to insufficient access rights. (Microsoft.SqlServer.Smo)
We setup a new Shared SQL server 2014 Web and transferred all SQL databases over. However when customers connect via SQL Management Studio they now get VIEW STATE error when right clicking on any table on any database.
Hi,I'm new at asp .net and have a problem. I have a page where the logged in user can add another user to his list of friends. To do this, I have a page where all the users are listed by using a datalist, and I have a form with an invisible field which passes the value of <%#DataBinder.Eval(Container.DataItem, "UserName")%> in post when the user clicks on "add as a friend" so that in the next page I can get that value and add it as well as the username of the logged in user to the table friendships. This is not working, can anyone help please? The code of the page with the datalist is:<script language="VB" runat="server"> Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) ' Session("username") = User.Identity.Name Dim CurrentUser As String CurrentUser = Membership.GetUser.ProviderUserKey.ToString() End Sub Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyCommand As SqlDataAdapter Dim CurrentUser As String CurrentUser = Membership.GetUser.ProviderUserKey.ToString() MyConnection = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True") MyCommand = New SqlDataAdapter("select u.*,f.buddyId as userNameIfFriend from aspnet_Users u left outer join aspnet_friendship f ON u.UserId=f.buddyId AND f.userId=@Param1 where IsAnonymous='False' and u.UserId<>@Param1", MyConnection) 'Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|;Integrated Security=True;User Instance=True MyCommand.SelectCommand.Parameters.AddWithValue("@Param1", CurrentUser) DS = New DataSet() MyCommand.Fill(DS, "aspnet_Users") MyDataList.DataSource = DS.Tables("aspnet_Users").DefaultView MyDataList.DataBind() End Sub</script><body> <br /> <ASP:DataList id="MyDataList" RepeatColumns="1" runat="server"> <ItemTemplate> <table cellpadding="10" style="font: 10pt verdana" cellspacing="0"> <tr> <td width="1" bgcolor="BD8672"/> <td valign="top"> </td> <td valign="top"> <div id="hey"><div id="dados"><b>Name: </b><%#DataBinder.Eval(Container.DataItem, "UserName")%><br><b>city: </b><%#DataBinder.Eval(Container.DataItem, "City")%><br></div> <div id="photo"><b>Photo: </b><%#DataBinder.Eval(Container.DataItem, "UserName")%><br>status: <form id="teste" name="teste" method="post" action="add_buddy.aspx"> <input name="UserId" type="hidden" id="UserId" value="<%#DataBinder.Eval(Container.DataItem, "UserName")%>" /> </form> <%#IIf(Container.DataItem("userNameIfFriend") Is DBNull.Value, "<a href='add_buddy.aspx'>Add as buddy</a> ", "Already buddy")%> </div> <p></div> <a href='<%# DataBinder.Eval(Container.DataItem, "UserName", "purchase.aspx?titleid={0}") %>' > </a> </td> </tr> </table> </ItemTemplate> </ASP:DataList></body></asp:Content>The code of the page where the user is redirected to add a friend and where I want to make the insert is: <script runat="server"> Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Dim CurrentUser As String CurrentUser = Membership.GetUser.ProviderUserKey.ToString() End Sub Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Dim CurrentUser As String CurrentUser = Membership.GetUser.ProviderUserKey.ToString() ' Declaring variables Dim UserId As String ' A Function to check if some field entered by user is empty ' Receiving values from Form UserId = (Request.Form("UserId")) Dim MyConnection As SqlConnection Dim MyCommand As SqlDataAdapter MyConnection = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True") MyCommand = New SqlDataAdapter("insert @Param2, @Param1 into aspnet_friendship.userId, aspnet_friendship.buddyId", MyConnection) MyCommand.SelectCommand.Parameters.AddWithValue("@Param1", CurrentUser) MyCommand.SelectCommand.Parameters.AddWithValue("@Param2", UserId) ' Creating Connection Object and opening the database Dim DS As DataSet DS = New DataSet() MyCommand.Fill(DS, "aspnet_friendship") ' Done. Close the connection End Sub </script> I am not sure if sending the information in a form in post to another page and executing the query there is the best option or if I can do it all within the if statement. I appreciate any help, since I am having difficulties in solving this.Thank you.
I have been successful with DTS packages and various SQL statements. However, I have a new challenge. I have a table in an SQL Server database. One of the columns is employee number and a column for department number(which is not populated) In a remote AS400 file I have the employees number and department number. I want to create a package to connect to remote table and update SQL Server table with department number where the two tables match on the employee number.