Can someone help me out if possible with this error when running a
program.
I have this code in the program
//-------------------------------------------
System.Data.OleDb.OleDbCommand vCommand = mConnection.CreateCommand();
string vSql = "INSERT INTO [Nodes]
(ParentID,aName,Description,R,G,B,Serial) " +
"VALUES(-1,'" + iName + "','" + iDescription + "'," + iRed.ToString()
+ "," + iGreen.ToString() +
"," + iBlue.ToString() + ",'" + iSerial + "')";
vCommand.CommandText = vSql;
vCommand.ExecuteNonQuery();
vSql="SELECT [NodeID] FROM [Nodes] WHERE [Serial]='" + iSerial + "'";
vCommand.CommandText=vSql;
// crashes on this line
int vRootNode = (int)vCommand.ExecuteScalar();
//-----------------------------------------------------
I get an error of "Specified cast is not valid." This is not my
program, I am trying to learn from it,
but its not going too well since I have to be fixing errors. I got
this project off of codeproject to
work with.
Is anyone able to tell what the problem is by looking at these few
lines of code?
Thanks
John