このエラーが発生します。 invoiceNum変数のwhileループに入ると、このエラーが発生します。私が間違っていることを助言してもらえますか?'System.Int32'型のオブジェクトを 'System.String'型にキャストできませんエラー
string selectSqlQuery = "SELECT * FROM Invoice"; //WHERE invoice_no=" + 1 + "";
//Create a command in C# to perform the sql Query
SqlCommand mySelectCommand = new SqlCommand(selectSqlQuery, myDBconnection);
//Creating the process for performing the command
SqlDataReader performCommand = mySelectCommand.ExecuteReader();
//Executing the command or running the command
// performCommand.Read();
while (performCommand.Read())
{
invoiceNum = Convert.ToInt16(performCommand.GetString(0));
pcBarcode = Convert.ToInt16(performCommand.GetString(1));
customerID = Convert.ToInt16(performCommand.GetString(2));
probDescr = performCommand.GetString(3);
empID = Convert.ToInt16(performCommand.GetString(4));
currentDate = Convert.ToDateTime(performCommand.GetString(5));
solution = performCommand.GetString(6); ;
partsID = Convert.ToInt16(performCommand.GetString(7));
labourPrice = Convert.ToInt16(performCommand.GetString(8));
totalPrice = Convert.ToInt16(performCommand.GetString(9));
// invoiceClass = new Invoice(invoiceNum, pcBarcode, customerID, probDescr, empID, currentDate, solution, partsID, labourPrice, totalPrice);
}
//Closing the execution of the command
performCommand.Close();
//Closing the connection
myDBconnection.Close();
}
InvoiceNum変数定義とInvoiceテーブル定義の最初の列は何ですか? – piotrwest
両方ともint型です – noor