473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Inserting data from web form not working?

Hi,

I'm using the following parameters in my web form:

cmdTest.Parameters.Add(New SqlParameter("@FirstN",
SqlDbType.NVarChar, 25))
cmdTest.Parameters.Add(New SqlParameter("@LastN",
SqlDbType.NVarChar, 25))
cmdTest.Parameters.Add(New SqlParameter("@Org",
SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New SqlParameter("@Addr1",
SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New SqlParameter("@City",
SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New SqlParameter("@Email",
SqlDbType.NVarChar, 50))
cmdTest.Parameters("@FirstN").Value = "FirstN"
cmdTest.Parameters("@LastN").Value = "LastN"
cmdTest.Parameters("@Org").Value = "Org"
cmdTest.Parameters("@Addr1").Value = "Addr1"
cmdTest.Parameters("@City").Value = "City"
cmdTest.Parameters("@Email").Value = "Email"

When I submit the form, somehow it didn't insert the info. I'm only
seeing "FirstN" "LastN" "Org" "Addr1" "City" and "Email" in the
corresponding columns in the database.

Could anyone help me with this? Am I using the right code?

Thanks,
hfk0

Feb 28 '06 #1
3 1115
hfk0,
Yes, because that is precisely what you are inserting - the literal string
values
"FirstN", "LastN" etc.
if you have Form Fields with these names, you probably want to use
this.FirstN.Text as the parameter value instead of the literal string
"FirstN".
What you get out is what you put in.
Hope that helps.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"hfk0" wrote:
Hi,

I'm using the following parameters in my web form:

cmdTest.Parameters.Add(New SqlParameter("@FirstN",
SqlDbType.NVarChar, 25))
cmdTest.Parameters.Add(New SqlParameter("@LastN",
SqlDbType.NVarChar, 25))
cmdTest.Parameters.Add(New SqlParameter("@Org",
SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New SqlParameter("@Addr1",
SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New SqlParameter("@City",
SqlDbType.NVarChar, 50))
cmdTest.Parameters.Add(New SqlParameter("@Email",
SqlDbType.NVarChar, 50))
cmdTest.Parameters("@FirstN").Value = "FirstN"
cmdTest.Parameters("@LastN").Value = "LastN"
cmdTest.Parameters("@Org").Value = "Org"
cmdTest.Parameters("@Addr1").Value = "Addr1"
cmdTest.Parameters("@City").Value = "City"
cmdTest.Parameters("@Email").Value = "Email"

When I submit the form, somehow it didn't insert the info. I'm only
seeing "FirstN" "LastN" "Org" "Addr1" "City" and "Email" in the
corresponding columns in the database.

Could anyone help me with this? Am I using the right code?

Thanks,
hfk0

Feb 28 '06 #2
Hi Peter,

Thanks for clearing things up. I replaced the literal string value with
FirstN.Text and it works like a charm.

Is there a difference between using this.FirstN.Text and FirstN.Text?

Also, I tried to add the following:

cmdTest.Parameters.Add(New SqlParameter("@State", SqlDbType.NChar, 2))
cmdTest.Parameters("@State").Value = State.SelectedItem.Value

and

cmdTest.Parameters.Add(New SqlParameter("@Phone", SqlDbType.VarChar,
10))
cmdTest.Parameters("@Phone").Value = Phone.Text

The state and phone values didn't get inserted into the database (I
tried using "numeric" instead of "varchar" but didn't help either). Any
clues?
Thanks again.

hfk0

Feb 28 '06 #3
"this" in C# (or "Me" in VB.NET) simply provides you with a convenient
reference to the current class that you are in. Type a dot (".") after that
and Intellisense kicks in for you.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"hfk0" wrote:
Hi Peter,

Thanks for clearing things up. I replaced the literal string value with
FirstN.Text and it works like a charm.

Is there a difference between using this.FirstN.Text and FirstN.Text?

Also, I tried to add the following:

cmdTest.Parameters.Add(New SqlParameter("@State", SqlDbType.NChar, 2))
cmdTest.Parameters("@State").Value = State.SelectedItem.Value

and

cmdTest.Parameters.Add(New SqlParameter("@Phone", SqlDbType.VarChar,
10))
cmdTest.Parameters("@Phone").Value = Phone.Text

The state and phone values didn't get inserted into the database (I
tried using "numeric" instead of "varchar" but didn't help either). Any
clues?
Thanks again.

hfk0

Feb 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ria Van Heerden | last post by:
How do I insert data from one form into two tables in a database? I am working with ASP pages and a MSSQL database Please let me know if one of you have done this before and how this is...
0
by: Lyn | last post by:
I am having a frustrating time trying to do a simple insert of a BMP picture into a Bound Object Frame using both VBA and the Insert | Object... dialog. I had a separate post thread going on this...
5
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If...
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
25
by: bseakgano | last post by:
I have developed a intranet . Using HTML , SQL and ASP . I have created a table with SQL is just fine . And design a form is just looks fine to me . But when I try to insert Data into the SQL I just...
2
by: Ravigandha | last post by:
Hello everybody, My question is how to insert special characters and symbols in Mysql5 database and how to retrieve them from database in php. Here i am inserting some data from a form,by post...
6
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the...
18
by: boss1 | last post by:
Hi all, i m having a problem with inserting data in oracle db. When i use form action =(call self page) then data is inserting properly.But problem with when using form...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.