473,409 Members | 1,983 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,409 software developers and data experts.

Link Button to sql table and store value entered in text box

I have one text box and submit button in one asp.net page. When users enter their email address in textbox and click submit button, i want to store that email address which comes from text box in sql server table. Sql database name is 'uprod'. Prod database has table named unsuscribe with column name email.
Can anyone help me? I appreciate your answer.

Thanks,
Pinky
Feb 9 '09 #1
5 4153
shweta123
692 Expert 512MB
Hi,

For storing the value of textbox into db table you can make use of the one of the following methods :

1> Write the sql statement into .Net code in order to insert the value of textbox into db table.

2>OR Write stored procedure for inserting the value into db table and call the stored procedure from your .Net code.

3> In order execute the stored procedure or sql query,set the appropriate properties of the command object.

4> Call the ExecuteNonQuery() method of the command object in order to run the stored procedure and sql query.
Feb 9 '09 #2
orked
49
hi
this code i use it for the same aim
Expand|Select|Wrap|Line Numbers
  1.   SqlConnection dbCon = new SqlConnection();
  2.         dbCon.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DB.mdf;Integrated Security=True;User Instance=True";
  3.         dbCon.Open();
  4.         SqlCommand sqlcom = new SqlCommand();
  5.         sqlcom.Connection = dbCon;
  6.         sqlcom.CommandType = CommandType.Text;
  7. sqlcom.CommandText = "insert into applicant(EmailAddress) values('" + EmailTextBox.Text + "');
  8.  SqlDataReader rdrData;
  9.  
  10.         rdrData = sqlcom.ExecuteReader();
  11.  
  12.  
  13.         GridView1.DataBind();
  14.         dbCon.Close();
  15.         Label13.Visible = false;
  16.         Label14.Visible = false;
  17.         OutputLabel.Visible = true;
you must change something in code in order to suitable for your application
Regards
orked
Feb 9 '09 #3
Hi Orked
Thank you very much for your code. I am going to try it now. Thank you very much again. I will let you know the result of this.
Thanks
Feb 9 '09 #4
Shweta,
Thanks for your ideas.




@shweta123
Feb 9 '09 #5
Frinavale
9,735 Expert Mod 8TB
Hi Pratimapaudel,

Please take a look at the article on how to use a database in your program and if you aren't using MSSql as your database, check out how to use a database in your program part II.

-Frinny
Feb 10 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: timmy_dale12 | last post by:
I need help with this one. I have a function that pastes a row. In each row i am pasting a link which is to call a date picker javascript function. This is the code that pastes the link : link =...
1
by: John Doe | last post by:
I have a PHP page that generates a list box with several options in it. I would like to have a "view" link next to the list box. When the user changes the contents of the list box, I would like...
6
by: Rod Snyder | last post by:
I'm trying to set up a page with an asp.net link button that would send a user to a certain page and on page load execute a specific stored procedure tied to the button on the previous page. The...
4
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the...
29
by: Tom wilson | last post by:
I can't believe this is such an impossibility... I have an asp.net page. It accepts data through on form fields and includes a submit button. The page loads up and you fill out some stuff. ...
1
by: Stephen D Cook | last post by:
In my form I have an option group with 3 option buttons. My form is tied to a table. the options are Temp, Permanent and Overtime. I have these inside a frame. I have an AddRecord button to enter...
4
by: Greg Scharlemann | last post by:
I'm trying to setup a dyamic dropdown list that displays a number of text fields based on the selected number in the dropdown. The problem I am running into is capturing the data already entered...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.