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

Insert Command Statement Help

Can anyone give me a quick little break down of what I would need to do to
insert information into a database onClick of and Submit button? I am new
to all of this and have done it with datagrids, but want to do it with just
textboxes filled in and on click of the Submit button that it would take
those boxes and insert a record into the database. This is for C#. below
is a little of what I have on the submit button but I don't think it is
correct.

private void btnSubmit_Click(object sender, System.EventArgs e)

{

this.oleDbInsertCommand1.CommandText = @"INSERT INTO
CONFERENCE.REQUEST(CUID, REQ_NUM, REQ_TYPE, CREATE_DT, START_DT, END_DT,
START_TM, END_TM, REQ_TTL, ATTENDEE_QTY, SETUP_DT, SETUP_TM, REQ_DESC,
CATERING_IND, WALK_THRU_IND, STORAGE_IND, BREAKOUT_RM_IND, MATERIALS_IND,
SPECIAL_REQ_TXT, REQ_STATUS, UPDATE_DT, UPDATED_BY_CUID,
CARD_EXPIRATION_VALUE, CHARGE_CD, BILL_METHOD_CD) VALUES (?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

this.oleDbInsertCommand1.Connection = this.oleDbConnection1;

this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("CUID",
System.Data.OleDb.OleDbType.VarChar, 8, "CUID"));

this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("REQ_NUM",
System.Data.OleDb.OleDbType.Decimal, 0,
System.Data.ParameterDirection.Input, false, ((System.Byte)(10)),
((System.Byte)(0)), "REQ_NUM", System.Data.DataRowVersion.Current, null));

Jul 21 '05 #1
3 1378
Hi Brian,

Assuming the sql command is correct, you'll have to add a parameter for each
? and assign a value (.Value property) to each.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Brian Conway" <Br**********@qwest.com> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
Can anyone give me a quick little break down of what I would need to do to
insert information into a database onClick of and Submit button? I am new
to all of this and have done it with datagrids, but want to do it with just textboxes filled in and on click of the Submit button that it would take
those boxes and insert a record into the database. This is for C#. below
is a little of what I have on the submit button but I don't think it is
correct.

private void btnSubmit_Click(object sender, System.EventArgs e)

{

this.oleDbInsertCommand1.CommandText = @"INSERT INTO
CONFERENCE.REQUEST(CUID, REQ_NUM, REQ_TYPE, CREATE_DT, START_DT, END_DT,
START_TM, END_TM, REQ_TTL, ATTENDEE_QTY, SETUP_DT, SETUP_TM, REQ_DESC,
CATERING_IND, WALK_THRU_IND, STORAGE_IND, BREAKOUT_RM_IND, MATERIALS_IND,
SPECIAL_REQ_TXT, REQ_STATUS, UPDATE_DT, UPDATED_BY_CUID,
CARD_EXPIRATION_VALUE, CHARGE_CD, BILL_METHOD_CD) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

this.oleDbInsertCommand1.Connection = this.oleDbConnection1;

this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("CUID",
System.Data.OleDb.OleDbType.VarChar, 8, "CUID"));

this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("REQ_NUM",
System.Data.OleDb.OleDbType.Decimal, 0,
System.Data.ParameterDirection.Input, false, ((System.Byte)(10)),
((System.Byte)(0)), "REQ_NUM", System.Data.DataRowVersion.Current, null));

Jul 21 '05 #2
Can you give me an example of how to do this. Are the insert commands in
the correct spot? Should I be putting these in the Submit button click
area?


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:e7**************@TK2MSFTNGP09.phx.gbl...
Hi Brian,

Assuming the sql command is correct, you'll have to add a parameter for each ? and assign a value (.Value property) to each.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Brian Conway" <Br**********@qwest.com> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
Can anyone give me a quick little break down of what I would need to do to insert information into a database onClick of and Submit button? I am new to all of this and have done it with datagrids, but want to do it with

just
textboxes filled in and on click of the Submit button that it would take
those boxes and insert a record into the database. This is for C#. below is a little of what I have on the submit button but I don't think it is
correct.

private void btnSubmit_Click(object sender, System.EventArgs e)

{

this.oleDbInsertCommand1.CommandText = @"INSERT INTO
CONFERENCE.REQUEST(CUID, REQ_NUM, REQ_TYPE, CREATE_DT, START_DT, END_DT,
START_TM, END_TM, REQ_TTL, ATTENDEE_QTY, SETUP_DT, SETUP_TM, REQ_DESC,
CATERING_IND, WALK_THRU_IND, STORAGE_IND, BREAKOUT_RM_IND, MATERIALS_IND, SPECIAL_REQ_TXT, REQ_STATUS, UPDATE_DT, UPDATED_BY_CUID,
CARD_EXPIRATION_VALUE, CHARGE_CD, BILL_METHOD_CD) VALUES (?, ?, ?, ?, ?,

?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

this.oleDbInsertCommand1.Connection = this.oleDbConnection1;

this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("CUID",
System.Data.OleDb.OleDbType.VarChar, 8, "CUID"));

this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("REQ_NUM",
System.Data.OleDb.OleDbType.Decimal, 0,
System.Data.ParameterDirection.Input, false, ((System.Byte)(10)),
((System.Byte)(0)), "REQ_NUM", System.Data.DataRowVersion.Current, null));


Jul 21 '05 #3
Hi,

"Brian Conway" <Br**********@qwest.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Can you give me an example of how to do this. Are the insert commands in
the correct spot?
I guess so.

Should I be putting these in the Submit button click area?
You might define the command and parameters at class level somewhere.
Within the submit method you just set parameter values.
See the
Inserting Data Into a SQL Database
..net help topic - it will give you an idea of what to do.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:e7**************@TK2MSFTNGP09.phx.gbl...
Hi Brian,

Assuming the sql command is correct, you'll have to add a parameter for each
? and assign a value (.Value property) to each.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Brian Conway" <Br**********@qwest.com> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
Can anyone give me a quick little break down of what I would need to do to
insert information into a database onClick of and Submit button? I am new to all of this and have done it with datagrids, but want to do it with

just
textboxes filled in and on click of the Submit button that it would
take those boxes and insert a record into the database. This is for C#. below is a little of what I have on the submit button but I don't think it is correct.

private void btnSubmit_Click(object sender, System.EventArgs e)

{

this.oleDbInsertCommand1.CommandText = @"INSERT INTO
CONFERENCE.REQUEST(CUID, REQ_NUM, REQ_TYPE, CREATE_DT, START_DT, END_DT, START_TM, END_TM, REQ_TTL, ATTENDEE_QTY, SETUP_DT, SETUP_TM, REQ_DESC,
CATERING_IND, WALK_THRU_IND, STORAGE_IND, BREAKOUT_RM_IND, MATERIALS_IND, SPECIAL_REQ_TXT, REQ_STATUS, UPDATE_DT, UPDATED_BY_CUID,
CARD_EXPIRATION_VALUE, CHARGE_CD, BILL_METHOD_CD) VALUES (?, ?, ?, ?,
?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

this.oleDbInsertCommand1.Connection = this.oleDbConnection1;

this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("CUID",
System.Data.OleDb.OleDbType.VarChar, 8, "CUID"));

this.oleDbInsertCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("REQ_NUM",
System.Data.OleDb.OleDbType.Decimal, 0,
System.Data.ParameterDirection.Input, false, ((System.Byte)(10)),
((System.Byte)(0)), "REQ_NUM", System.Data.DataRowVersion.Current,

null));



Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bill Kellaway | last post by:
Hi there - this should be fairly simple for someone. Basically I can't figure out how to pass the parameters from ASP to a Stored Procedure on SQL. Here's my code: I just need to help in...
8
by: 73blazer | last post by:
Hello, I'm looking for a way to make some of my insert templates more readable by placing comments in between the values. I cannot seem to find a way to do this with DB2, is there a way? I'm...
4
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). ...
6
by: Manuel Canas | last post by:
Hello there, This is my SQL Insert Statement to insert a single into a table on a database; INSERT tb_test VALUES(' & _ txtTest1.Text & "' " & _ txtTest2.Text & "' " & _ txtPrice.Text & "')"
7
by: Kevin Lawrence | last post by:
Hi all I want to do "INSERT INTO Table (Blob) Values('blobdataasstring')". ...rather than using the parameter driven method, is it possible? And if so what encoder do I use to convert the...
3
by: Ian Semmel | last post by:
The generated INSERT statement in a typed dataset has an INSERT statement followed by a SELECT statement which gets (I think) the value of the autoincremented ID. Question. How do I get hold of...
4
by: Andrevv | last post by:
Hi all! Im totaly new in programing, so i need some help if someone can help me... Im programing in VS 2005, C# language and using MS SQL Server 2005 . So, after i fill my table with 10 records,...
7
by: anu b | last post by:
Hi I need to use Clr trigger for insert command My code is as below I am using SQL server 2005 and VS 2008.... but after running this code i didnt get the result as i expexted it shows the...
1
by: gilesy | last post by:
Hi, I have a ploblem with an insert statement using an access database, I have the same code with a sql database which works but it doesn't seem to work on access. Could someone please help. For...
3
by: gilesy | last post by:
Hi, I have a ploblem with an insert statement using an access database, I have the same code with a sql database which works but it doesn't seem to work on access. Could someone please help. For i =...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
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...
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,...
0
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...

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.