Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Assigning data to a Parameter?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Assigning data to a Parameter?

 Post Reply Post Reply
Author
Arkelias View Drop Down
Newbie
Newbie


Joined: 26 January 2006
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arkelias Quote  Post ReplyReply Direct Link To This Post Topic: Assigning data to a Parameter?
    Posted: 26 January 2006 at 10:25pm

I am trying to insert a record into a database, and am having a lot of trouble getting the data from the text boxes I created to bind to the Parameters.  Anyone have any idea how I can get the text property of a text box to match up with a parameter so I can assign it to a field?  Thus far all that happens is I add a blank record and the strings in the text boxes are completely ignored...

Below is the code I have so far:
 

<Script runat="server">

Private Sub InsertBorrower(ByVal Source As Object, ByVal e As EventArgs)

'Dim Social_Security_Number As Parameter

'Social)Security_Number =

'Social_Security_Number.DefaultValue = txtSocial.Text

SqlDataSource1.Insert()

End Sub

</Script>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString1 %>"

DeleteCommand="DELETE FROM [Borrower] WHERE [Social Security Number] = @Social_Security_Number"

InsertCommand="INSERT INTO [Borrower] ([First Name], [Last Name], [Middle Name], [Social Security Number], [Current Address], [Co/Main Borrower], [Current Street Address], [Current City], [Current State], [Current Zip], [Income]) VALUES (@First_Name, @Last_Name, @Middle_Name, @Social_Security_Number, @Current_Address, @column1, @Current_Street_Address, @Current_City, @Current_State, @Current_Zip, @Income)"

ProviderName="<%$ ConnectionStrings:DatabaseConnectionString1.ProviderName %>"

SelectCommand="SELECT [First Name] AS First_Name, [Last Name] AS Last_Name, [Middle Name] AS Middle_Name, [Social Security Number] AS Social_Security_Number, [Current Address] AS Current_Address, [Co/Main Borrower] AS column1, [Current Street Address] AS Current_Street_Address, [Current City] AS Current_City, [Current State] AS Current_State, [Current Zip] AS Current_Zip, [Income] FROM [Borrower]"

UpdateCommand="UPDATE [Borrower] SET [First Name] = @First_Name, [Last Name] = @Last_Name, [Middle Name] = @Middle_Name, [Current Address] = @Current_Address, [Co/Main Borrower] = @column1, [Current Street Address] = @Current_Street_Address, [Current City] = @Current_City, [Current State] = @Current_State, [Current Zip] = @Current_Zip, [Income] = @Income WHERE [Social Security Number] = @Social_Security_Number">

<InsertParameters>

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

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

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

<asp:Parameter Name="Social_Security_Number" Type="Int16" DefaultValue= txtSocial.text />

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

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

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

<asp:Paramet

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 27 January 2006 at 4:11pm
You don't need to redefine the parameters just use:

Protected Sub InsertBorrower(ByVal sender As Object, ByVal e As System.EventArgs)
   SqlDataSource1.InsertParameters.Item("First_Name").DefaultValue = txtFirst.Text
   SqlDataSource1.InsertParameters.Item("Last_Name").DefaultValue = txtLast.Text
   SqlDataSource1.InsertParameters.Item("Middle_Name").DefaultValue = txtMiddle.Text
    'and so on
   SqlDataSource1.Insert()
End Sub
Back to Top
Arkelias View Drop Down
Newbie
Newbie


Joined: 26 January 2006
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arkelias Quote  Post ReplyReply Direct Link To This Post Posted: 27 January 2006 at 4:33pm
You sir are a god!  Thanks for the help!
Back to Top
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2006 at 6:06am
Ackk...And that was a question to which I knew the answer to. Bad luck for me. I am never fast enough.
David.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.