473,750 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

24 New Member
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 4161
shweta123
692 Recognized Expert Contributor
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 New Member
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
pratimapaudel
24 New Member
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
pratimapaudel
24 New Member
Shweta,
Thanks for your ideas.




@shweta123
Feb 9 '09 #5
Frinavale
9,735 Recognized Expert Moderator Expert
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
5107
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 = document.createElement('a'); link.href ="javascript:show_calendar('document.form1.date',document.form1.date.value);"; img = document.createElement('img'); img.setAttribute("src","H:Diverse\\cal.gif"); link.appendChild(img);
1
9710
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 the view link to update to point to the image representing that selection. So for example, if the list box held names of images I would want the view link to always point at the correct image. To further complicate this matter, the selections...
6
3865
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 link would be in a nav area and be something like "update". It would send the user to the main page and execute the stored procedure associated with the update functionality. I'm new to this area of .NET and would appreciate any suggestions,...
4
4833
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 value of the "id" field of that record as a URL parameter. Can someone tell me how to do this.
29
4005
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. The submit button posts the page back to the server. The button code detects an entry error and sends the page back to the user. This all works. However, if the user presses the Back button at this point, we go back and all the form values are...
1
4506
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 the data into the table. After the record is Added the option buttons are emptied. I want to require the person to click one of the option buttons, which enters the type of employee it is. In the click event of the AddRecord button I have the...
4
2633
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 before the list is repopulated. For example, suppose the user selects 3 in the drop down list and 3 text fields are shown. If the user populates the 3 text fields with data and decides to change the drop down to a list of 4 or 5, how do I capture...
5
6760
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 link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
4
4586
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 reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no...
0
9584
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9398
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9345
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9257
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8265
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6811
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6081
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4894
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2227
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.