473,473 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

inserting values using a asp.net form

5 New Member
Hi.
I want to insert data to sybase using an HTML form in asp.net.

I have the following code:
Expand|Select|Wrap|Line Numbers
  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. using Sybase.Data.AseClient;
  13.  
  14. public partial class test : System.Web.UI.Page
  15. {
  16.  
  17.  
  18.     private AseConnection TempDMT_conn = new AseConnection(ConfigurationSettings.AppSettings["connectionString"]);
  19.  
  20.     protected void Page_Load(object sender, EventArgs e)
  21.     {
  22.  
  23.     }
  24.     protected void Button1_Click(object sender, EventArgs e)
  25.     {
  26.  
  27.  
  28.         string username = txtusername.Text;
  29.         string password = txtpassword.Text;
  30.  
  31.             TempDMT_conn.Open ();
  32.  
  33.  
  34.             AseDataAdapter adapter = new AseDataAdapter();
  35.             adapter.MissingMappingAction = MissingMappingAction.Passthrough;
  36.             adapter.MissingSchemaAction = MissingSchemaAction.Add;
  37.             adapter.SelectCommand = new AseCommand("Select * from login", TempDMT_conn);
  38.             adapter.InsertCommand = new AseCommand("INSERT INTO login(username,password)" + "VALUES(@username,@password)", TempDMT_conn);
  39.             adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;
  40.             AseParameter parm = new AseParameter("@username", AseDbType.VarChar, 10);
  41.             parm.SourceColumn = "username";
  42.             parm.SourceVersion = DataRowVersion.Current;
  43.             adapter.InsertCommand.Parameters.Add(parm);
  44.             parm = new AseParameter("@password", AseDbType.VarChar, 10);
  45.             parm.SourceColumn = "password";
  46.             parm.SourceVersion = DataRowVersion.Current;
  47.             adapter.InsertCommand.Parameters.Add(parm);
  48.  
  49.             DataTable dataTable = new DataTable("login");
  50.  
  51.             int rowCount = adapter.Fill(dataTable);
  52.             DataRow row1 = dataTable.NewRow();
  53.             row1[0] = "teresama";
  54.             row1[1] = "terry";
  55.             dataTable.Rows.Add(row1);
  56.             int recordsAffected = adapter.Update(dataTable);
  57.  
  58.             dataTable.Clear();
  59.             rowCount = adapter.Fill(dataTable);
  60.  
  61.             TempDMT_conn.Close();
  62.  
  63.  
  64.  
  65.     }
  66. }
This does connect to sybase but now I want to get values from TextBox and insert it to sybase.

Could anyone help?
Oct 28 '11 #1
1 1819
Frinavale
9,735 Recognized Expert Moderator Expert
If you have a TextBox on your asp.net Page you should be able to just access it's Text property to retrieve the text.

Unless your TextBox is part of another control (like a GridView for example). In this case, you first need to retrieve the TextBox from the control and then access it's Text property.
Oct 28 '11 #2

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

Similar topics

0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
1
by: pmud | last post by:
I have an ASP.NET web application using C# code. I am trying to insert values from a web form into an SQL database. I am using SQL COMMAND object for this. I need to know HOW TO INSERT THE RADIO...
3
by: awebguynow | last post by:
in other words, Can I make client side mod's before I submit a form and Post ? I guess its just a matter of cycling through the form elements and setting value to null (or empty string) for...
1
by: ram achar | last post by:
please send me C# code for inserting values into database sql server2005 *** Sent via Developersdex http://www.developersdex.com ***
3
by: hellboss | last post by:
Hi ! Iam working in asp.net in Visual Studio 2005. I tried to insert some datas from the webform's interfaces into the SQL Server 05 database using a stored procedure. Since iam new to asp.net,im...
1
by: Mel | last post by:
On the SERVER SIDE, I need to get some values from form Elements and save the values into a file. Is this possible using Javascipt ? any exmple is highly appreciated
9
by: Bunty | last post by:
I am not beginer of this language. I've worked on this language for 2 or 3 months.But now i have a problem to inserting values in the database.It gives me error that DATABASE NOT SELECTED. I am...
3
by: bilalkhan | last post by:
Hello I m using MS Acces 2007, I need to create a form through which a user can enter all the parameter values in the form and these values will automatically picked by a query: Here is the...
9
by: i12know | last post by:
Hi guys, I had some problem inserting values a structure array in C++. I had define for example struct UNITS { unsigned char VariableA; unsigned char VariableB; // the...
1
by: arvindmishra | last post by:
i m inserting values in access database it displays message value is inserted but value is not ptresent in database. I m using following code OleDbConnection cnn = new OleDbConnection(); ...
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
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
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,...
1
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...
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.