943,833 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1064
  • ASP.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 23rd, 2009
0

add data into a sql with a drop down

Expand Post »
hi

this may sound simple but i can not get it to work i have try for about 5-6 weeks now and this my last hope


all my project is to make a job dater base that workers can add jobs and cliences can see there job but i am stuck on
the user (user being the worker) fill out a form(this would be a new job) and then sumit it to a dater base.
the form will include

job name = text box
job status = drop down box
hazarads = drop down box
design staff = drop down box
description = multiline text box

and a few more but if i know how to do them then i can figure out how do the others.

any help please


thanks alot



ANY questions please please ask


using asp.net would perfure vb but that desprate will use c#
Last edited by motters; Aug 23rd, 2009 at 12:17 pm. Reason: add detail
Reputation Points: 10
Solved Threads: 1
Light Poster
motters is offline Offline
37 posts
since Aug 2009
Aug 23rd, 2009
-1

Re: add data into a sql with a drop down

hi frnd , can u plz explain ur question more clearly...or send me ur question on mine id <EMAIL SNIPPED>
Last edited by peter_budo; Aug 23rd, 2009 at 4:13 pm. Reason: Keep It On The Site - Do not post asking for an answer to be sent to you via email or PM.
Reputation Points: 0
Solved Threads: 8
Posting Whiz
sonia sardana is offline Offline
326 posts
since Mar 2008
Aug 23rd, 2009
0

Re: add data into a sql with a drop down

hi frnd , can u plz explain ur question more clearly...or send me ur question on mine id <EMAIL SNIPPED>

ok thanks for helping me

all i want to do is to add data into sql dater base using a drop down box,text box, and mulitly line text box
Last edited by peter_budo; Aug 23rd, 2009 at 4:13 pm. Reason: Snipping email from quote
Reputation Points: 10
Solved Threads: 1
Light Poster
motters is offline Offline
37 posts
since Aug 2009
Aug 23rd, 2009
0

Re: add data into a sql with a drop down

ks so simple it is..I m showing u the code dat add data to SQL database but from textbox,U just change dropdown here..


ASP.NET Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12.  
  13. public partial class FrmRegistration : System.Web.UI.Page
  14. {
  15.  
  16. SqlConnection conn = new SqlConnection("Data Source=SONIA-B408A4159\\SQLEXPRESS;Initial catalog=sonia;Integrated Security=true");
  17. string query;
  18. SqlCommand cmd;
  19.  
  20.  
  21. protected void btnSubmit_Click(object sender, EventArgs e)
  22. {
  23. query = "Insert into UserInfo values(@name,@email)";
  24. cmd = new SqlCommand(query, conn);
  25. conn.Open();
  26. cmd.Parameters.AddWithValue("@name", txtName.Text);
  27. cmd.Parameters.AddWithValue("@email", txtEmail.Text);
  28. cmd.ExecuteNonQuery();
  29. conn.Close();
  30.  
  31.  
  32. }
  33. }

ASP.NET Syntax (Toggle Plain Text)
  1. create table UserInfo(Name varchar(100),EMail varchar(100))
  2. select * from UserInfo
  3. delete from UserInfo
Last edited by sonia sardana; Aug 23rd, 2009 at 1:26 pm.
Reputation Points: 0
Solved Threads: 8
Posting Whiz
sonia sardana is offline Offline
326 posts
since Mar 2008
Aug 23rd, 2009
0

Re: add data into a sql with a drop down

motters: Please post your project. Zip it and upload the entire project.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 23rd, 2009
0

Re: add data into a sql with a drop down

Click to Expand / Collapse  Quote originally posted by sknake ...
motters: Please post your project. Zip it and upload the entire project.
there is one problem with that i am in test stages i am testing that i can do everything needed for the project. so not starting project till i know how to slove this problem. so i have know thing to upload.


--------------------------------------------------------------------------------

also i have i problem with the code supply

c# Syntax (Toggle Plain Text)
  1. protected void btnSubmit_Click(object sender, EventArgs e)
  2. {
  3. query = "Insert into UserInfo values(@name,@email)";
  4. cmd = new SqlCommand(query, conn);
  5. conn.Open();
  6. cmd.Parameters.AddWithValue("@name",[B] txtName[/B].Text);
  7. cmd.Parameters.AddWithValue("@email", [B]txtEmai[/B]l.Text);
  8. cmd.ExecuteNonQuery();
  9. conn.Close();
  10.  
  11.  
  12. }



where is says txtName and txtEmail i have a red line uder and it says "txtName does not exsist in the current context"
same for txtEmail.
on my page i do have two text boxs one called
txtName and the other one
txtEmail

what have i done wrong


thanks alot for your help
Last edited by peter_budo; Aug 23rd, 2009 at 4:14 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 1
Light Poster
motters is offline Offline
37 posts
since Aug 2009
Aug 23rd, 2009
0

Re: add data into a sql with a drop down

Please use code tags when posting code on daniweb:

[code=csharp]
...code here...
[/code]


It sounds like you're creating the controls dynamically. It is impossible to tell what is really going on without an uploaded sample project. You can create a new project and move over enough code to reproduce the issue.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 23rd, 2009
0

Re: add data into a sql with a drop down

ok sorry for not using he code tag i will from now on sorry


i will get together a sample project as soon as i can

thanks for all your help
Reputation Points: 10
Solved Threads: 1
Light Poster
motters is offline Offline
37 posts
since Aug 2009
Aug 23rd, 2009
0

Re: add data into a sql with a drop down

just remove the txtName.Text & type it again..Dont cut & paste it again...
Reputation Points: 0
Solved Threads: 8
Posting Whiz
sonia sardana is offline Offline
326 posts
since Mar 2008
Aug 23rd, 2009
0

Re: add data into a sql with a drop down

just remove the txtName.Text & type it again..Dont cut & paste it again...

i have just try that am it did not work should the text box be in a formview?
Reputation Points: 10
Solved Threads: 1
Light Poster
motters is offline Offline
37 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: DataReader Vs DataSet
Next Thread in ASP.NET Forum Timeline: how to dynamically set the text of a label using the text from textbox?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC