이 오류가 계속 발생합니다. 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