I'm trying to materialize data into 2 (later 3) tables simultaneously using a C# console application. I want to implement first name, last name and user ID in table "Users", the user ID will be automatically incremented.
The same userID should also be implemented into table "profile" along with porilfeID (again done automatically via auto-increment) and profileName.
But somewhere it throws an error that the command text is not initialized correctly and I can no longer figure out what I'm doing wrong.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
P粉3373859222024-04-05 18:22:36
You create cmd = new MySqlCommand();
but never set its .CommandText
property. Calling cmd.ExecuteNonQuery();
will fail because there is no CommandText
to execute.
Set cmd.CommandText
or change the constructor to cmd = new MySqlCommand("text here", conn);
.