J
Jim H
Learning ADO.NET is proving to be difficult.
The last statement below produces the error indicated right
above it (Parameter not found) -- and I have no ideal as to
why. The Count Property for the Parameters Collection
contains 1. What am I overlooking?
// -- Code Block --------------------------------------------------
// Define sqlDataAdapter3
System.Data.SqlClient.SqlDataAdapter sqlDataAdapter3;
// Define sqlSelectCommend3
System.Data.SqlClient.SqlCommand sqlSelectCommand3;
// Create object sqlDataAdapter3
sqlDataAdapter3 = new System.Data.SqlClient.SqlDataAdapter();
// Create object sqlSelectCommand3
sqlSelectCommand3 = new System.Data.SqlClient.SqlCommand();
// Load the desired sql text command into sqlSelectCommand3
sqlSelectCommand3.CommandText = "SELECT FNXApplication, FNXOriginalName, " +
"FNXSource, FNXNewName, FNXComment FROM " +
"FieldNameXRef WHERE (FNXApplication = @FNXApplication)";
// Add one parameter (FNXApplication) to sqlSelectCommand3 <=== Parameter Added
sqlSelectCommand3.Parameters.Add( new System.Data.SqlClient.SqlParameter(
"@FNXApplication", System.Data.SqlDbType.VarChar, 5, "FNXApplication" ));
// Tell sqlDataAdapter3 to use sqlSelectCommand3 as it's SELECT Command
sqlDataAdapter3.SelectCommand = sqlSelectCommand3;
// Produces Error: An SqlParameter with ParameterName 'FNXApplication' is <=== Error
// not contained by this SqlParameterCollection.
sqlDataAdapter3.SelectCommand.Parameters["FNXApplication"].Value = selectedApp;
// -- End Code Block ----------------------------------------------
The last statement below produces the error indicated right
above it (Parameter not found) -- and I have no ideal as to
why. The Count Property for the Parameters Collection
contains 1. What am I overlooking?
// -- Code Block --------------------------------------------------
// Define sqlDataAdapter3
System.Data.SqlClient.SqlDataAdapter sqlDataAdapter3;
// Define sqlSelectCommend3
System.Data.SqlClient.SqlCommand sqlSelectCommand3;
// Create object sqlDataAdapter3
sqlDataAdapter3 = new System.Data.SqlClient.SqlDataAdapter();
// Create object sqlSelectCommand3
sqlSelectCommand3 = new System.Data.SqlClient.SqlCommand();
// Load the desired sql text command into sqlSelectCommand3
sqlSelectCommand3.CommandText = "SELECT FNXApplication, FNXOriginalName, " +
"FNXSource, FNXNewName, FNXComment FROM " +
"FieldNameXRef WHERE (FNXApplication = @FNXApplication)";
// Add one parameter (FNXApplication) to sqlSelectCommand3 <=== Parameter Added
sqlSelectCommand3.Parameters.Add( new System.Data.SqlClient.SqlParameter(
"@FNXApplication", System.Data.SqlDbType.VarChar, 5, "FNXApplication" ));
// Tell sqlDataAdapter3 to use sqlSelectCommand3 as it's SELECT Command
sqlDataAdapter3.SelectCommand = sqlSelectCommand3;
// Produces Error: An SqlParameter with ParameterName 'FNXApplication' is <=== Error
// not contained by this SqlParameterCollection.
sqlDataAdapter3.SelectCommand.Parameters["FNXApplication"].Value = selectedApp;
// -- End Code Block ----------------------------------------------