Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 03-03-2011, 01:05 AM   #1 (permalink)
Bazinga!!!!!
 
sanoob.tv's Avatar
 
Join Date: May 2009
Location: koottanad,kerela
Posts: 159
Exclamation "Help needed" visual web developer 2008(asp.net c#)


i hav been working on asp.net(c#) for past few days.
i created a table named "sum" having coloumns(registerno,name)under database "trial".

in my aspx web page,i have provided 2 text boxes(Textbox1 for registerno & textbox2 for name)and a button.

what im looking for is a way to insert the contents of the textboxes to the table"sum";i have the button click event,the contents of the text box,and the sql command to insert;

can any one tell me the code for the same,
thnx in advance
sanoob.tv is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 03-03-2011, 07:21 PM   #2 (permalink)
XLr8
 
arpanmukherjee1's Avatar
 
Join Date: Sep 2008
Posts: 637
Default Re: "Help needed" visual web developer 2008(asp.net c#)

if u really tried u can find that code anywhere on the net

u r a beginner, so, just this one time i will give the code ::

Code:
 
         private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection sqlConnection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\trial.mdf;Integrated Security=True;User Instance=True"); //change the connection string accordingly
            SqlCommand sqlCmd = new SqlCommand(string.Format("INSERT INTO [sum] VALUES ({0}, '{1}')", TextBox1.Text, TextBox2.Text), sqlConnection);//first is int type and second varchar type
            try{
                 sqlConnection.Open();
                 int rowsAffected = sqlCmd.ExecuteNonQuery();
                 sqlConnection.Close();
                 Label1.Text = rowsAffected.ToString() + " record(s) inserted sucessfully";
            }
            catch(Exception ex)
            {
                  Label1.Text = "Error: " + ex.Message;
             }
             finally{
             sqlConnection.Close();
             }
          }
include namespace
Code:
using System.Data.SqlClient;
and put a label with id Label1

i suppose the code is fairly easy to understand. if in doubt break up the code and try to find it on the net

i recommend a great site. used it in my early days :: http://csharp.net-informations.com/
__________________
Quote:
There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.

Last edited by arpanmukherjee1; 03-03-2011 at 07:42 PM.
arpanmukherjee1 is offline   Reply With Quote
Old 10-03-2011, 06:38 PM   #3 (permalink)
Broken In
 
Join Date: Aug 2010
Location: The God's Own Country
Posts: 116
Default Re: "Help needed" visual web developer 2008(asp.net c#)

Coded it self, and yes it was a home work problem.
@arpanmukherjee1 : Your code is little confusing to me since i'm a beginner.
Anyway thanks...
__________________
AMD Athlon II X4 635 || Asus M4A78LT-MLE || Kingston 2X2GB 1333MHz DDR3 || WDC Green 500GB || CM Elite 310 || Dell E2010H
manujohn is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx
- by clinton

Advertisement




All times are GMT +5.5. The time now is 12:24 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2