einzugeben Ich bekomme diesen Fehler weiterhin. Dieser Fehler tritt auf, wenn er in die while-Schleife der Variable invoiceNum übernommen wird. Kannst du mir bitte sagen, was ich falsch mache?Kann Objekt des Typs 'System.Int32' nicht umwandeln, um 'System.String' Fehler
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();
}
Wie lautet die Definition der Rechnungsnummer und die erste Spalte in der Definition der Rechnungstabelle? – piotrwest
beide sind vom Typ int – noor