|
List Info
Thread: Subtracting from user input
|
|
| Subtracting from user input |
  United States |
2007-03-27 12:24:22 |
Hi everyone,
First post by this noob . . .
I need to integrate sections of this code:
protected void Update_Click(object sender, EventArgs e)
{
int myValue = Int16.Parse(TextBox1.Text) - 45;
string connect = "Data
Source=localhost\sqlexpress;Initial
Catalog=pubs;Integrated Security=True;";
System.Data.SqlClient.SqlConnection sqlconnect =
new
System.Data.SqlClient.SqlConnection(connect);
string command = "insert into Value(value)
values( value)";
System.Data.SqlClient.SqlCommand sqlcommand = new
System.Data.SqlClient.SqlCommand();
sqlcommand.CommandText = command;
sqlcommand.Connection = sqlconnect;
System.Data.SqlClient.SqlParameter p = new
System.Data.SqlClient.SqlParameter();
p.ParameterName = " value";
p.Value = myValue;
p.SqlDbType = System.Data.SqlDbType.SmallInt;
sqlcommand.Parameters.Add(p);
sqlconnect.Open();
sqlcommand.ExecuteNonQuery();
sqlconnect.Close();
}
into this code:
void Button_Click(object s, EventArgs e)
{
SqlConnection conDB_1004714;
string strInsert;
SqlCommand cmdInsert;
conDB_1004714 = new
SqlConnection("Server=p3swhsql-
v02.shr.phx3.secureserver.net;UID=consultant;PWD=????;databa
se=DB_1004714");
strInsert = "Insert data ( ClientName,
Clientid, ConsultID,
PRGM, MTGDATE, LENGTH, ccharge, TRAVmins, MILEAGE, TOLLS,
MAT, FOOD,
OTHER, NOTES ) Values ( ClientLastName, ClientId,
ConsultantID,
Program, MeetingDate, Length, CancelCharge, TravelMinutes,
Mileage, Tolls, Material, Food,
Other, Notes )";
cmdInsert = new SqlCommand(strInsert,
conDB_1004714);
cmdInsert.Parameters.Add(" ClientLastName",
ClientName.SelectedItem);
cmdInsert.Parameters.Add(" ClientId", Clientid.SelectedItem);
cmdInsert.Parameters.Add(" ConsultantID",
ConsultID.SelectedItem);
cmdInsert.Parameters.Add(" Program", PRGM.SelectedItem);
cmdInsert.Parameters.Add(" MeetingDate", MTGDATE.Text);
cmdInsert.Parameters.Add(" Length", LENGTH.Text);
cmdInsert.Parameters.Add(" CancelCharge",
ccharge.SelectedItem);
cmdInsert.Parameters.Add(" TravelMinutes", TRAVmins.Text);
cmdInsert.Parameters.Add(" Mileage", MILEAGE.Text);
cmdInsert.Parameters.Add(" Tolls", TOLLS.Text);
cmdInsert.Parameters.Add(" Material", MAT.Text);
cmdInsert.Parameters.Add(" Food", FOOD.Text);
cmdInsert.Parameters.Add(" Other", OTHER.Text);
cmdInsert.Parameters.Add(" Notes", NOTES.Text);
conDB_1004714.Open();
cmdInsert.ExecuteNonQuery();
conDB_1004714.Close();
}
Namely, the sections I need to merge from the first chunk
into the
second are:
int myValue = Int16.Parse(TextBox1.Text) - 45;
and
string command = "insert into Value(value) values( value)";
What I need to accomplish is for a number input in one of
the fields
to have the number 45 subtracted from it, before it is
written to the
DB.
Thanking everyone beforehand (I am doing this for the female
epitome
of a PHB, mega nightmare, donŽt ask me how I got myself into
it, but
when this last little thing is done, IŽll be free to run
away as fast
as I can)
M.Roman
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "ASP.Net Community" group.
To post to this group, send email to aspnet googlegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Subtracting from user input |
  United States |
2007-03-29 14:15:26 |
Thanks folks.
On Mar 27, 12:24 pm, "Maurice R."
<mauricero... gmail.com> wrote:
> Hi everyone,
>
> First post by this noob . . .
>
> I need to integrate sections of this code:
>
> protected void Update_Click(object sender, EventArgs
e)
> {
> int myValue = Int16.Parse(TextBox1.Text) - 45;
>
> string connect = "Data
Source=localhost\sqlexpress;Initial
> Catalog=pubs;Integrated Security=True;";
> System.Data.SqlClient.SqlConnection sqlconnect
= new
> System.Data.SqlClient.SqlConnection(connect);
> string command = "insert into Value(value)
values( value)";
> System.Data.SqlClient.SqlCommand sqlcommand =
new
> System.Data.SqlClient.SqlCommand();
> sqlcommand.CommandText = command;
> sqlcommand.Connection = sqlconnect;
>
> System.Data.SqlClient.SqlParameter p = new
> System.Data.SqlClient.SqlParameter();
> p.ParameterName = " value";
> p.Value = myValue;
> p.SqlDbType = System.Data.SqlDbType.SmallInt;
> sqlcommand.Parameters.Add(p);
>
> sqlconnect.Open();
> sqlcommand.ExecuteNonQuery();
>
> sqlconnect.Close();
>
> }
>
> into this code:
>
> void Button_Click(object s, EventArgs e)
> {
> SqlConnection conDB_1004714;
> string strInsert;
> SqlCommand cmdInsert;
> conDB_1004714 = new
SqlConnection("Server=p3swhsql-
>
v02.shr.phx3.secureserver.net;UID=consultant;PWD=????;databa
se=DB_1004714");
> strInsert = "Insert data ( ClientName,
Clientid, ConsultID,
> PRGM, MTGDATE, LENGTH, ccharge, TRAVmins, MILEAGE,
TOLLS, MAT, FOOD,
> OTHER, NOTES ) Values ( ClientLastName, ClientId,
ConsultantID,
> Program, MeetingDate, Length, CancelCharge, TravelMinutes,
> Mileage, Tolls, Material, Food,
Other, Notes )";
> cmdInsert = new SqlCommand(strInsert,
conDB_1004714);
> cmdInsert.Parameters.Add(" ClientLastName",
> ClientName.SelectedItem);
> cmdInsert.Parameters.Add(" ClientId", Clientid.SelectedItem);
> cmdInsert.Parameters.Add(" ConsultantID",
> ConsultID.SelectedItem);
> cmdInsert.Parameters.Add(" Program", PRGM.SelectedItem);
> cmdInsert.Parameters.Add(" MeetingDate", MTGDATE.Text);
> cmdInsert.Parameters.Add(" Length", LENGTH.Text);
> cmdInsert.Parameters.Add(" CancelCharge",
> ccharge.SelectedItem);
> cmdInsert.Parameters.Add(" TravelMinutes", TRAVmins.Text);
> cmdInsert.Parameters.Add(" Mileage", MILEAGE.Text);
> cmdInsert.Parameters.Add(" Tolls", TOLLS.Text);
> cmdInsert.Parameters.Add(" Material", MAT.Text);
> cmdInsert.Parameters.Add(" Food", FOOD.Text);
> cmdInsert.Parameters.Add(" Other", OTHER.Text);
> cmdInsert.Parameters.Add(" Notes", NOTES.Text);
> conDB_1004714.Open();
> cmdInsert.ExecuteNonQuery();
> conDB_1004714.Close();
> }
>
> Namely, the sections I need to merge from the first
chunk into the
> second are:
>
> int myValue = Int16.Parse(TextBox1.Text) - 45;
>
> and
>
> string command = "insert into Value(value)
values( value)";
>
> What I need to accomplish is for a number input in one
of the fields
> to have the number 45 subtracted from it, before it is
written to the
> DB.
>
> Thanking everyone beforehand (I am doing this for the
female epitome
> of a PHB, mega nightmare, donŽt ask me how I got myself
into it, but
> when this last little thing is done, IŽll be free to
run away as fast
> as I can)
>
> M.Roman
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "ASP.Net Community" group.
To post to this group, send email to aspnet googlegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-2]
|
|