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

WTH

Nick

<UpdateParameters>

<asp:Parameter Name="DevelopmentArea" Type="String"/>

<asp:Parameter Name="DevelopmentGoals" Type="String" />

<asp:Parameter Name="DevelopmentPlans" Type="String" />

<asp:Parameter Name="CurrentStatus" Type="String" />

<asp:Parameter Name="FutureState" Type="String" />

<asp:Parameter Name="DetermineFactor" Type="String"/>

<asp:Parameter Name="MentorRequested" Type="Boolean" DefaultValue="False"/>

<asp:Parameter Name="MentorList" Type="String"/>

<asp:Parameter Name="CheckPointDate" Type="DateTime" />

<asp:Parameter Name="DateUpdated" Type="DateTime" />

<asp:Parameter Name="PlanPKID" Type="Int32" />

</UpdateParameters>

View 6 Replies


ADVERTISEMENT

One Form To Update Different SQL Tables Based Upon Form Selection

Apr 16, 2008

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

View 3 Replies View Related

Formview Doesn't Update

Dec 13, 2006

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?  

View 2 Replies View Related

Update From A FormView To An Oracle DB

Jul 23, 2007

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() + "&lt;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 = ""; } }}   

View 1 Replies View Related

Formview Does Not Update Database

May 21, 2006

HiI'm using a FormView to allow my administrator to add/edit/remove questions/answers to the FAQ of my helpdesk.Now I figured out how to use the FormView to adjust the data, the only thing the FormView does NOT do, is actually update the database, it does not give any errors, it just doesn't do anything.This is the code:  <asp:SqlDataSource ID="sdsAdminFaqDetails" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
DeleteCommand="DELETE FROM [Faq] WHERE [QuestionID] = @QuestionID"
InsertCommand="INSERT INTO [Faq] ([Question], [Answer]) VALUES (@Question, @Answer)"
SelectCommand="SELECT * FROM [Faq]"
UpdateCommand="UPDATE [Faq] SET [Question] = @Question, [Answer] = @Answer WHERE [QuestionID] = @QuestionID">
<DeleteParameters>
<asp:Parameter Name="QuestionID" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Question" />
<asp:Parameter Name="Answer" />
<asp:Parameter Name="QuestionID" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Question" />
<asp:Parameter Name="Answer" />
</InsertParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" DataSourceID="sdsAdminFaqDetails">
<ItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ReadOnly="True" ID="txtQuestion" runat="server" Text='<%# Eval("Question") %>' Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ReadOnly="True" ID="txtAnswer" runat="server" Text='<%# Eval("Answer") %>' Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnEdit" runat="server" Text="Wijzig" CommandName="Edit" /> <asp:Button ID="btnInsert" runat="server" Text="Nieuw" CommandName="New" /></td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ID="txtQuestion" runat="server" Text='<%# Bind("Question") %>' Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ID="txtAnswer" runat="server" Text='<%# Bind("Answer") %>' Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnUpdate" runat="server" Text="Bevestig" CommandName="Update" /> <asp:Button ID="btnDelete" runat="server" Text="Verwijder" CommandName="Delete" /></td>
</tr>
</table>
</EditItemTemplate>
<InsertItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ID="txtQuestion" runat="server" Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ID="txtAnswer" runat="server" Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnInsert" runat="server" Text="Voeg toe" CommandName="Insert" /> <asp:Button ID="btnCancel" runat="server" Text="Annuleer" CommandName="Cancel" /></td>
</tr>
</table>
</InsertItemTemplate>
<EmptyDataTemplate>
U hebt niet geselecteerd welke vraag u wilt wijzigen.
</EmptyDataTemplate>
</asp:FormView>
hope one of you sees where i made a mistake, or forgot about something...thx for your help

View 12 Replies View Related

Need Help With Update Link In FormView - URGENT

Dec 7, 2006

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>
 

View 5 Replies View Related

Dynamically Add Update Parameter To Formview

May 3, 2007

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

End Sub Thanks

View 9 Replies View Related

FormView - Update Process Completes With No Error But Records Is Not Changed

Jul 24, 2006

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.

View 3 Replies View Related

Data Disappear - SQL Server 2000 / ASP Interface

Jul 20, 2005

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

View 10 Replies View Related

Excel 2007 Data Mining Add-in Disappear

Oct 10, 2007



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.

Any idea you can help me get my add in back?

View 12 Replies View Related

Master Data Services :: Setting Read Permission On Entity Attribute Makes Model Disappear

May 21, 2013

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.

See before and after snapshots below.

View 8 Replies View Related

Update Web Form

Dec 29, 2005

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

View 1 Replies View Related

Form Update Problem

Jan 8, 2008

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

 
Thanks in a dvance
 
Dave

View 4 Replies View Related

Problems With SQL And Update From Form

Jun 19, 2008

I am trying to upgrade my site from Microsoft Access to SQL and it runs fine except when I try do the update from the webform. BElow is my code. If someone can see why it is happening that would be great:
 The error I get is: Line 1: Incorrect syntax near 'nvarchar'.
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="HIGHWAY" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
&nbsp;<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NCCAUTHConnectionString %>"
DeleteCommand="DELETE FROM [TblMain] WHERE [ID] = @ID" InsertCommand="INSERT INTO [TblMain] ([ID], [Auth No], [Caller], [Date], [Time], [H S No], [Type], [Contractor], [Origin], [Destination], [Modification Requested], [Trailer Number], [Pull Date], [Pull Time], [Contractor Date], [Contractor Time], [CDO], [Message Number and comments]) VALUES (@ID, @Auth_No, @Caller, @Date, @Time, @H_S_No, @Type, @Contractor, @Origin, @Destination, @Modification_Requested, @Trailer_Number, @Pull_Date, @Pull_Time, @Contractor_Date, @Contractor_Time, @CDO, @Message_Number_and_comments)"
SelectCommand="SELECT * FROM [TblMain]" UpdateCommand="UPDATE [TblMain] SET [Auth No] = @Auth_No, [Caller] = @Caller, [Date] = @Date, [Time] = @Time, [H S No] = @H_S_No, [Type] = @Type, [Contractor] = @Contractor, [Origin] = @Origin, [Destination] = @Destination, [Modification Requested] = @Modification_Requested, [Trailer Number] = @Trailer_Number, [Pull Date] = @Pull_Date, [Pull Time] = @Pull_Time, [Contractor Date] = @Contractor_Date, [Contractor Time] = @Contractor_Time, [CDO] = @CDO, [Message Number and comments] = @Message_Number_and_comments WHERE [ID] = @ID">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Auth_No" Type="String" />
<asp:Parameter Name="Caller" Type="String" />
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="Time" Type="String" />
<asp:Parameter Name="H_S_No" Type="String" />
<asp:Parameter Name="Type" Type="String" />
<asp:Parameter Name="Contractor" Type="String" />
<asp:Parameter Name="Origin" Type="String" />
<asp:Parameter Name="Destination" Type="String" />
<asp:Parameter Name="Modification_Requested" Type="String" />
<asp:Parameter Name="Trailer_Number" Type="String" />
<asp:Parameter Name="Pull_Date" Type="String" />
<asp:Parameter Name="Pull_Time" Type="String" />
<asp:Parameter Name="Contractor_Date" Type="String" />
<asp:Parameter Name="Contractor_Time" Type="String" />
<asp:Parameter Name="CDO" Type="String" />
<asp:Parameter Name="Message_Number_and_comments" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Auth_No" Type="String" />
<asp:Parameter Name="Caller" Type="String" />
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="Time" Type="String" />
<asp:Parameter Name="H_S_No" Type="String" />
<asp:Parameter Name="Type" Type="String" />
<asp:Parameter Name="Contractor" Type="String" />
<asp:Parameter Name="Origin" Type="String" />
<asp:Parameter Name="Destination" Type="String" />
<asp:Parameter Name="Modification_Requested" Type="String" />
<asp:Parameter Name="Trailer_Number" Type="String" />
<asp:Parameter Name="Pull_Date" Type="String" />
<asp:Parameter Name="Pull_Time" Type="String" />
<asp:Parameter Name="Contractor_Date" Type="String" />
<asp:Parameter Name="Contractor_Time" Type="String" />
<asp:Parameter Name="CDO" Type="String" />
<asp:Parameter Name="Message_Number_and_comments" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" PostBackUrl="~/Test.aspx" Text="Add New Authorization" />
<asp:GridView ID="GridView1" runat="server" CellPadding="3" DataSourceID="SqlDataSource1" GridLines="Vertical"
Style="font-size: 8pt; font-family: Arial" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" Font-Bold="True" AllowSorting="True">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<Columns>
<asp:CommandField ShowEditButton="True" />
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" /></asp:GridView>
</asp:Content>

View 4 Replies View Related

Unable To Update SQL Table From A Web Form

Jan 20, 2006

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
 
Thank you for your much needed help in advance.
 

View 3 Replies View Related

Web Form To Update SQL Server 2005 DB

Jul 26, 2007

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.

Marc

View 1 Replies View Related

Query In Dataview/update Form

Dec 23, 2006

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?

Thanks,

View 4 Replies View Related

Form Field Returns Name With Double Quotes Instead Of Single Quote During Update Process.

Oct 3, 2007

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?

View 1 Replies View Related

Clicking Through To Errors

May 14, 2007

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?

Thanks

View 2 Replies View Related

How To Add Data To SQL Via Web Form?

Feb 19, 2008

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

View 2 Replies View Related

Can&#39;t Sort By Clicking Column Header In EM

Jan 18, 2001

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.

Thanks!

View 2 Replies View Related

Error When Clicking OK On Edit Of Task

Oct 13, 2006

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.

View 4 Replies View Related

INSERTING DATA WITH WEB FORM

Apr 25, 2008

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() {
}
 
</script>
<style type="text/css">
.style1
{width: 34%;
}
.style2
{width: 144px;
}</style>
</head><body>
<br />
 
<form id="form1" runat="server">
 
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<br /><asp:SqlDataSource ID="SqlDataSource1" runat="server"
InsertCommand="INSERT INTO property(provinceName, cityName, ownerName, ownerPhone, numOfRooms, rent, ownerEmail, listPeriod, addInfo)
VALUES(@provinceName, @cityName, @ownerName, @ownerPhone, @numOfRooms, @rent, @ownerEmail, @listPeriod, @addInfo)">
<InsertParameters><asp:ControlParameter ControlID="provinceddl2" Name="provinceName"
PropertyName="SelectedValue" /><asp:ControlParameter ControlID="cityddl2" Name="cityName"
PropertyName="SelectedValue" /><asp:ControlParameter ControlID="nameTxtBox" Name="ownerName"
PropertyName="Text" /><asp:ControlParameter ControlID="phoneTxtBox" Name="ownerPhone"
PropertyName="Text" /><asp:ControlParameter ControlID="roomsTxtBox" Name="numOfRooms"
PropertyName="Text" />
<asp:ControlParameter ControlID="rentTxtBox" Name="rent" PropertyName="Text" /><asp:ControlParameter ControlID="EmailTxtBox" Name="ownerEmail"
PropertyName="Text" /><asp:ControlParameter ControlID="listPeriodddl" Name="listPeriod"
PropertyName="SelectedValue" /><asp:ControlParameter ControlID="addInfoTxtBox" Name="addInfo"
PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>
<br />
<br />
<br />
<br />
 
<table cellspacing="1" class="style1">
<tr>
<td class="style2">
Contact Name:</td>
<td>
<asp:TextBox ID="nameTxtBox" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
Contact phone:</td>
<td>
<asp:TextBox ID="phoneTxtBox" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
Province:</td>
<td>
<asp:DropDownList ID="provinceddl2" runat="server" Width="205px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style2">
City:</td>
<td>
<asp:DropDownList ID="cityddl2" runat="server" Width="205px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style2">
Email:</td>
<td>
<asp:TextBox ID="EmailTxtBox" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
Number of Rooms:</td>
<td>
<asp:TextBox ID="roomsTxtBox" runat="server" Width="80px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
Monthly Rent:</td>
<td>
<asp:TextBox ID="rentTxtBox" runat="server" Width="80px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
Period to list:</td>
<td><asp:DropDownList ID="listPeriodddl" runat="server"
DataSourceID="listPeriodSqlDataSource" DataTextField="listDays"
DataValueField="listDays" Width="85px">
</asp:DropDownList><asp:SqlDataSource ID="listPeriodSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:PlaceConnectionString1 %>"
SelectCommand="SELECT [listDays] FROM [listPeriod]"></asp:SqlDataSource>
</td>
</tr>
<tr>
<td class="style2">
Additional Infomation:</td>
<td><asp:TextBox ID="addInfoTxtBox" runat="server" Rows="5" TextMode="MultiLine"
Width="200px"></asp:TextBox>
</td>
</tr>
</table>
<br />
;&nbsp;&nbsp;&nbsp;<asp:Button ID="insertSubmitBtn" runat="server" Text="Submit" Width="140px"
onclick="insertSubmitBtn_Click" />
<br/>
 <cc1:CascadingDropDown
ID="Provincecdd2"
runat="server"
TargetControlID="Provinceddl2"
Category="Province"
PromptText="Select a province"
ServicePath="Location.asmx"
ServiceMethod="GetProvince" />
<br /><cc1:CascadingDropDown
ID="Citycdd2"
runat="server"
TargetControlID="Cityddl2"
ParentControlID="Provinceddl2"
Category="City"
PromptText="Select a city"
ServicePath="Location.asmx"
ServiceMethod="GetCity" />
 
</div></form>
</body>
</html>
 
Server Error .


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

 
Hotkwesi

View 1 Replies View Related

Insert Data Form Xls

Dec 22, 2006

Hello,

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

but it doesn't work

what's the correct syntax to make it work ???

Thanks a lot & merry Xmas... :)

View 8 Replies View Related

How To Populate Grid From SQLDataSource When Clicking On Button

Nov 20, 2007

how to populate grid from SQLDataSource  when clicking  on button

View 2 Replies View Related

How To Enable Auto-scroll By Middle Clicking

Oct 8, 2015

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.

View 5 Replies View Related

Direct Export After Clicking Generate Report

Feb 14, 2008

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.

View 3 Replies View Related

Validate While Clicking The View Report Button

Apr 3, 2007

I want to validate my input report parameters while user clicks the View Report Button. How can I accompalish this in SSRS.



ex: Report parameters should accept only numberic values.

View 4 Replies View Related

Error When Right Clicking On Database And Selecting Properties

Oct 31, 2007



Can anyone help?

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)


I am using SQL server 2005.

View 4 Replies View Related

Setup And Upgrade :: Right Clicking Any Table Gives Error 300

Jun 26, 2015

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. 

Check screenshot.

View 4 Replies View Related

Adding Data From A Form To A Database

Nov 15, 2007

Very basic question here but I need to add a form to a page so it adds content, its as simple as that.  I've done this kind of using a <asp.Formview> tag and it works, but becuase I think I've used a form view I have to click add to insert data first.  Should I be using the <asp:formview> tag or is it a problem with the templates?
 <asp:FormView ID="FormView1" runat="server" DataKeyNames="ContentID" DataSourceID="ObjectDataSource1">                                      <InsertItemTemplate>                        Resource :<asp:DropDownList ID="ResourceIDTextBox" runat="server" Text='<%# Bind("ResourceID") %>' DataSourceID="ObjectDataSource2"                            DataTextField="Resource" DataValueField="ResourceID">                        </asp:DropDownList><br />                        Headline:                        <asp:TextBox ID="HeadlineTextBox" runat="server" Text='<%# Bind("Headline") %>' Width="451px"></asp:TextBox><br />                        Date:                        <asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>'>                        </asp:TextBox><br />                        Body:                                        <FTB:FreeTextBox id="FreeTextBox1" runat="Server" Text='<%# Bind("Body") %>' Width="542px" />                        <br />                        ImageURL:                        <asp:TextBox ID="ImageURLTextBox" runat="server" Text='<%# Bind("ImageURL") %>'>                        </asp:TextBox><br />                        OpeningPara:                        <asp:TextBox ID="OpeningParaTextBox" runat="server" Text='<%# Bind("OpeningPara") %>'>                        </asp:TextBox><br />                        Ret:                        <asp:TextBox ID="RetTextBox" runat="server" Text='<%# Bind("Ret") %>'>                        </asp:TextBox><br />                        Man:                        <asp:TextBox ID="ManTextBox" runat="server" Text='<%# Bind("Man") %>'>                        </asp:TextBox><br />                        Pro:                        <asp:TextBox ID="ProTextBox" runat="server" Text='<%# Bind("Pro") %>'>                        </asp:TextBox><br />                        Com:                        <asp:TextBox ID="ComTextBox" runat="server" Text='<%# Bind("Com") %>'>                        </asp:TextBox><br />                        IndustryID:                        <asp:TextBox ID="IndustryIDTextBox" runat="server" Text='<%# Bind("IndustryID") %>'>                        </asp:TextBox><br />                        ContentTitle:                        <asp:TextBox ID="ContentTitleTextBox" runat="server" Text='<%# Bind("ContentTitle") %>'>                        </asp:TextBox><br />                        Status:                        <asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>'>                        </asp:TextBox><br />                        Pub:                        <asp:TextBox ID="PubTextBox" runat="server" Text='<%# Bind("Pub") %>'>                        </asp:TextBox><br />                        Fin:                        <asp:TextBox ID="FinTextBox" runat="server" Text='<%# Bind("Fin") %>'>                        </asp:TextBox><br />                        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"                            Text="Insert">                        </asp:LinkButton>                        <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"                            Text="Cancel">                        </asp:LinkButton>                    </InsertItemTemplate>                    <ItemTemplate>                                             <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"                            Text="Click here to Add New Content">                        </asp:LinkButton>                    </ItemTemplate>                </asp:FormView>
                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"                    InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="ContentADDMethod"                    TypeName="DataSet2TableAdapters.ContentADDAdapter" UpdateMethod="Update">                    <DeleteParameters>                        <asp:Parameter Name="Original_ContentID" Type="Int32" />                    </DeleteParameters>                    <UpdateParameters>                        <asp:Parameter Name="ResourceID" Type="Int32" />                        <asp:Parameter Name="Headline" Type="String" />                        <asp:Parameter Name="Date" Type="String" />                        <asp:Parameter Name="Body" Type="String" />                        <asp:Parameter Name="ImageURL" Type="String" />                        <asp:Parameter Name="OpeningPara" Type="String" />                        <asp:Parameter Name="Ret" Type="String" />                        <asp:Parameter Name="Man" Type="String" />                        <asp:Parameter Name="Pro" Type="String" />                        <asp:Parameter Name="Com" Type="String" />                        <asp:Parameter Name="IndustryID" Type="Int32" />                        <asp:Parameter Name="ContentTitle" Type="String" />                        <asp:Parameter Name="Status" Type="String" />                        <asp:Parameter Name="Pub" Type="String" />                        <asp:Parameter Name="Fin" Type="String" />                        <asp:Parameter Name="Original_ContentID" Type="Int32" />                        <asp:Parameter Name="ContentID" Type="Int32" />                    </UpdateParameters>                    <InsertParameters>                        <asp:Parameter Name="ResourceID" Type="Int32" />                        <asp:Parameter Name="Headline" Type="String" />                        <asp:Parameter Name="Date" Type="String" />                        <asp:Parameter Name="Body" Type="String" />                        <asp:Parameter Name="ImageURL" Type="String" />                        <asp:Parameter Name="OpeningPara" Type="String" />                        <asp:Parameter Name="Ret" Type="String" />                        <asp:Parameter Name="Man" Type="String" />                        <asp:Parameter Name="Pro" Type="String" />                        <asp:Parameter Name="Com" Type="String" />                        <asp:Parameter Name="IndustryID" Type="Int32" />                        <asp:Parameter Name="ContentTitle" Type="String" />                        <asp:Parameter Name="Status" Type="String" />                        <asp:Parameter Name="Pub" Type="String" />                        <asp:Parameter Name="Fin" Type="String" />                    </InsertParameters>                </asp:ObjectDataSource>                                                      <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" InsertMethod="Insert"                      OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DataSet2TableAdapters.ResourcesTableAdapter">                      <InsertParameters>                          <asp:Parameter Name="Resource" Type="String" />                      </InsertParameters>                  </asp:ObjectDataSource>
 

View 1 Replies View Related

Insert Post Data From A Form Into Db

Dec 26, 2007

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>            &nbsp;&nbsp;</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.   

View 3 Replies View Related

Updates Form Remote Data

Oct 13, 2005

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.

View 3 Replies View Related







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