K
kagitas via .NET 247
(Type your message here)
Code taken from MSDN:
public void CreateMySqlCommand(SqlConnection myConnection,
string mySelectQuery, SqlParameter[] myParamArray) {
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection);
myCommand.CommandText = "SELECT CustomerID, CompanyName FROM Customers WHERE Country = @Country AND City = @City";
myCommand.Parameters.Add(myParamArray);
for (int j=0; j<myParamArray.Length; j++)
{
myCommand.Parameters.Add(myParamArray[j]) ;
}
string myMessage = "";
for (int i = 0; i < myCommand.Parameters.Count; i++)
{
myMessage += myCommand.Parameters.ToString() + "\n";
}
MessageBox.Show(myMessage);
}
In this query "SELECT CustomerID, CompanyName FROM Customers WHERE Country = @Country AND City = @City";
how do we know which parameter of the parameter array is passed to the query.
For Eg: what would be the value of @Country as we are not using any indexer.
Thanks in adavnce,
Jaya.
Code taken from MSDN:
public void CreateMySqlCommand(SqlConnection myConnection,
string mySelectQuery, SqlParameter[] myParamArray) {
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection);
myCommand.CommandText = "SELECT CustomerID, CompanyName FROM Customers WHERE Country = @Country AND City = @City";
myCommand.Parameters.Add(myParamArray);
for (int j=0; j<myParamArray.Length; j++)
{
myCommand.Parameters.Add(myParamArray[j]) ;
}
string myMessage = "";
for (int i = 0; i < myCommand.Parameters.Count; i++)
{
myMessage += myCommand.Parameters.ToString() + "\n";
}
MessageBox.Show(myMessage);
}
In this query "SELECT CustomerID, CompanyName FROM Customers WHERE Country = @Country AND City = @City";
how do we know which parameter of the parameter array is passed to the query.
For Eg: what would be the value of @Country as we are not using any indexer.
Thanks in adavnce,
Jaya.