c# - Storing Number in an integer from sql Database -


I'm using the table again and the column page in the database in the index that type in the database but when I I want to store page IDX

The specified cast is not valid.

Here is the code

  string sq; String conString = "provider = Microsoft.ACE.OLEDB.12.0; data source = D: \ Deliverable4.accdb"; Protected OleDbConnection RMS Connection; Protected OleDbDataAdapter rMSDataAdapter; Secure dataset dataset; Protected DataTable dataTable; Protected Detroit Detroe; Click the  

button

  sql = "Choose Resume from Page Indax"; RMSConnection = New Oleodeconnection (Konstring); RMSDataAdapter = New OleDbDataAdapter (sql, rMSConnection); Dataset = new dataset ("PINXX"); RMSata adapter.phill (dataset, "resume"); DataTable = Dataset Tables ["Resume"];  

int pIndex = (int) dataTable.Rows [0] [0];

  rMSConnection.Close (); If (Pandyx == 0) {Response.Redirect ("Create Resume-1.aspx"); } And if (pIndex == 1) {Response.Redirect ("Create Resume - 2.aspx"); } And if (pIndex == 2) {Response.Redirect ("Create Resume-3.aspx"); }}  

I am getting the error in this line

  int pIndex = (int) dataTable.Rows [0] [0];  

Can I suggest humbly in a different way of doing this?: < / P>

  string conString = "..."; // & lt; - Using your connection string (IDB connection connection = new orbestation (Konstring)) {// ^^^ Interface type depends less on your code on a particular backend! Connection.Open (); {Idb command command = contact connection. Quote ()) {// ^^ command command CommonText = "Selection PageIndex Redeem"; Object scalar = command.ExecuteScalar (); // ^ ExecuteScalar reads the first value in the first column // of the result set; Or if he fails to do so, throw zero (scalar == empty) if it returns ...; // Unexpected results from database! Throw (scalar == DBNull.Value) if ...; // Tell !? Int pIndex = (int) scaler; Switch (PIDX) {Case: Answer: Response. Redirect ("Start again - 1.aspx create"); break; Case 1: Reaction. Redirect ("Start Again - Create 2.aspx"); break; Case 2: Reaction. Redirect ("Resume - Create 3.aspx"); break; Default: throw ...; // Unexpected results from databases? }}} Finally {connection.Close (); // (Exception will be executed even when thrown!)}}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -