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

Pointing to the current record identifier

Hi,
I am trying to implement a SQLServer database update inside a catch loop and
I'm having difficulties pointing to the row to update using the current
order's OrderID primary key Identifier in the table.

The block:

catch (Exception MailEx) {
//Tag record as FAIL
SqlCommand sqlCmd = new SqlCommand ( );
sqlCmd.Connection = new SqlConnection ("server =
'LMM-MB-DATA,25886';Database = 'Oligo_Order'; Trusted_Connection=Yes");
// define insert command parameters
sqlCmd.CommandText = "UPDATE Orders SET Tag = 'FAIL' WHERE
OrderID = 'Order.OrderNum'";
sqlCmd.Connection.Open ( );
// do SET
sqlCmd.ExecuteNonQuery ( );

Response.Redirect("Oligo_Confirm.aspx?Error=True") ;

Doesn't work: Error converting data type varchar to numeric (Order.OrderNum
returns a String and the OrderID column in SQL is of type Numeric).
I therefore tried this:

Order.OrderInt = sqlCmd.Parameters["@Id"].Value.ToInt32();

And I get this: 'object' does not contain a definition for 'ToInt32'

If I replace 'Order.OrderNum' with an actual record Identifier in the table
the command works fine:
sqlCmd.CommandText = "UPDATE Orders SET Tag = 'FAIL' WHERE OrderID = 26";

Thanks for your help.
Stephan.

Nov 17 '05 #1
1 1193
To get an int:

System.Int32.Parse(yourstring);
Something like that
"Stephan Bour" <sb***@niaid.nih.gov> wrote in message news:BBC2EE34.A792%sb***@niaid.nih.gov...
Hi,
I am trying to implement a SQLServer database update inside a catch loop and
I'm having difficulties pointing to the row to update using the current
order's OrderID primary key Identifier in the table.

The block:

catch (Exception MailEx) {
//Tag record as FAIL
SqlCommand sqlCmd = new SqlCommand ( );
sqlCmd.Connection = new SqlConnection ("server =
'LMM-MB-DATA,25886';Database = 'Oligo_Order'; Trusted_Connection=Yes");
// define insert command parameters
sqlCmd.CommandText = "UPDATE Orders SET Tag = 'FAIL' WHERE
OrderID = 'Order.OrderNum'";
sqlCmd.Connection.Open ( );
// do SET
sqlCmd.ExecuteNonQuery ( );

Response.Redirect("Oligo_Confirm.aspx?Error=True") ;

Doesn't work: Error converting data type varchar to numeric (Order.OrderNum
returns a String and the OrderID column in SQL is of type Numeric).
I therefore tried this:

Order.OrderInt = sqlCmd.Parameters["@Id"].Value.ToInt32();

And I get this: 'object' does not contain a definition for 'ToInt32'

If I replace 'Order.OrderNum' with an actual record Identifier in the table
the command works fine:
sqlCmd.CommandText = "UPDATE Orders SET Tag = 'FAIL' WHERE OrderID = 26";

Thanks for your help.
Stephan.

Nov 17 '05 #2

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

Similar topics

4
by: John | last post by:
Hi Is there a way to print/e-mail the current record as it appears on a form? Thanks Regards
1
by: Tony | last post by:
I have a form in access that has 5 fields for a certain record: 1)Date mailed, 2)Date received, 3)Date completed 4)Foreign Content amount and 5)record number. If the foreign content (FC)is >15% of...
2
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another form. The command button takes me to another...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
1
by: Richard Coutts | last post by:
I have a Continuous Form where each record has a button that activates another form that simplifies entering values into the record. The activated form has the equivalent of a "Done" button. I'd...
3
by: Maria | last post by:
Is there another way to delete the current record in a subform from the main form, another subform or a sub-subform other than setting focus on a field in the subform and using run command...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set...
1
by: Jeff Karli | last post by:
I think I now understand how to use this forum. I hope I am following the rules now. I am a college student working on a database project that requires some VBA coding for the Event Procedures and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.