There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
When submitting ASP.NET form, SQL Server fields only show the first letter


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
ultimaincubu's Avatar
Member with 36 posts.
 
Join Date: Jan 2005
Experience: Advanced
30-Nov-2005, 02:14 PM #1
When submitting ASP.NET form, SQL Server fields only show the first letter
Hi, I'm new around here and am stumped. I have created a form where I submit the information into a SQL Server 2000 table. When I submit the information through the form, only the first character of each field populates inside of the SQL table. This happens for every field except for two, zip and comments. The zip field is numeric and the comments field is text. All the other fields are varchar fields; and these are the fields with the problems. I have attempted to change the data type to text, but that did not work either. I am doing this through a stored procedure I created.

Here is the asp code:


Public Class WebForm1

Inherits System.Web.UI.Page

Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox

Protected WithEvents txtLastName As System.Web.UI.WebControls.TextBox

Protected WithEvents txtAddress1 As System.Web.UI.WebControls.TextBox

Protected WithEvents txtAddress2 As System.Web.UI.WebControls.TextBox

Protected WithEvents txtCity As System.Web.UI.WebControls.TextBox

Protected WithEvents txtZip As System.Web.UI.WebControls.TextBox

Protected WithEvents txtEmail As System.Web.UI.WebControls.TextBox

Protected WithEvents txtPhone As System.Web.UI.WebControls.TextBox

Protected WithEvents txtComments As System.Web.UI.WebControls.TextBox

Protected WithEvents ddlState As System.Web.UI.WebControls.DropDownList

Protected WithEvents ddlGift1 As System.Web.UI.WebControls.DropDownList

Protected WithEvents ddlGift2 As System.Web.UI.WebControls.DropDownList

Protected WithEvents ddlGift3 As System.Web.UI.WebControls.DropDownList

Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm

Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection

Protected WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand

Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection()

Me.SqlCommand1 = New System.Data.SqlClient.SqlCommand()

'

'SqlConnection1

'

Me.SqlConnection1.ConnectionString = "data source=NDAVENPORT2;initial catalog=Bluestreak;integrated security=SSPI;persi" & _

"st security info=False;workstation id=NDAVENPORT2;packet size=4096"

'

'SqlCommand1

'

Me.SqlCommand1.CommandText = "dbo.[InsertFreeOrders]"

Me.SqlCommand1.CommandType = System.Data.CommandType.StoredProcedure

Me.SqlCommand1.Connection = Me.SqlConnection1

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@firstname", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@lastname", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@address1", System.Data.SqlDbType.VarChar, 100))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@address2", System.Data.SqlDbType.VarChar, 100))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@city", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@state", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@zip", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, False, CType(18, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@email", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@phone", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@item1", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@item2", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@item3", System.Data.SqlDbType.VarChar, 50))

Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@comments", System.Data.SqlDbType.VarChar, 2147483647))

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

If IsValid Then

SqlCommand1.Parameters("@firstname").Value = txtFirstName.Text

SqlCommand1.Parameters("@lastname").Value = txtLastName.Text

SqlCommand1.Parameters("@address1").Value = txtAddress1.Text

SqlCommand1.Parameters("@address2").Value = txtAddress2.Text

SqlCommand1.Parameters("@city").Value = txtCity.Text

SqlCommand1.Parameters("@state").Value = ddlState.SelectedItem.Text

SqlCommand1.Parameters("@zip").Value = txtZip.Text

SqlCommand1.Parameters("@email").Value = txtEmail.Text

SqlCommand1.Parameters("@phone").Value = txtPhone.Text

SqlCommand1.Parameters("@item1").Value = ddlGift1.SelectedItem.Text

SqlCommand1.Parameters("@item2").Value = ddlGift2.SelectedItem.Text

SqlCommand1.Parameters("@item3").Value = ddlGift3.SelectedItem.Text

SqlCommand1.Parameters("@comments").Value = txtComments.Text

SqlConnection1.Open()

SqlCommand1.ExecuteNonQuery()

SqlConnection1.Close()

Response.Redirect("Success.aspx")

End If

End Sub

End Class


My stored procedure looks like this:

CREATE PROCEDURE dbo.InsertFreeOrders
(
@firstname varchar( 50 ),
@lastname varchar( 50 ),
@address1 varchar( 100 ),
@address2 varchar( 100 ),
@city varchar( 50 ),
@state varchar( 50 ),
@zip numeric,
@email varchar( 50 ),
@phone varchar( 50 ),
@item1 varchar( 50 ),
@item2 varchar( 50 ),
@item3 varchar( 50 ),
@comments text
)
AS
Insert FreeOrders
(
o_first_name,
o_last_name,
o_address_1,
o_address_2,
o_city,
o_state,
o_zip,
o_email,
o_phone,
o_item_1,
o_item_2,
o_item_3,
o_comments
) Values (
@firstname,
@lastname,
@address1,
@address2,
@city,
@state,
@zip,
@email,
@phone,
@item1,
@item2,
@item3,
@comments
)
GO

So it is working, just not completely and I am stumped here. Any help would be great! Thanks.
Mithrilhall's Avatar
Senior Member with 781 posts.
 
Join Date: Mar 2001
Location: AU Microscopii
Experience: Studying for my CCNA
01-Dec-2005, 01:28 AM #2
Do a response.write or write the fields in question to the page before submitting them to the database. What do the results look like?

Also, try using the code tags next time. It'll make it easy for everyone else to read your code.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:02 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.