 |
 |
database connection
|
 |
|
 |
|
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status:
Offline
|
|
I am trying to connect to an access database via c#/.net. i am able to connect to the database and write (not the correct information, but something). i am trying to get numbers from combo boxes and insert them into a table. the code i am using to try and get the combo box value from is being posted into the table; not the value itself. i am also getting a type mismatch on the average field and the avg variable. the average field is set to the numeric type and avg is a double.
Code:
sql = "INSERT INTO TeacherEval ([Interesting, Useful, Relevant], [Appropriate Pace], [Clear & Understandable], [Effective Teaching Aids], [Combined Theory & application], [Used Examples, Demos, Hands-on], [Knew Subject Matter], [Organized Lessons], [Created Mutual Respect], [Encouraged Participation], [Prepared, Started, Ended, on Time], [Fair & Timely Grading], [Positive Attitude & Appearance], [Enforced Policies Consistently], [Overall Evaluation], [Average])" +
"values (':combo1.Text', ':combo2.Text', ':combo3.Text', ':combo4.Text', ':combo5.Text', ':combo6.Text', ':combo7.Text', ':combo8.Text', ':combo9.Text', ':combo10.Text', ':combo11.Text', ':comb12.Text', ':combo13.Text', ':combo14.Text', ':combo15.Text', 'avg')";
sql is a string variable that is used to be set as the oleDbCommand() for the sql query into the database. the text that is being sent to the database, when i don't include average and avg, is the string i am using to try and get the value from the combo box.
thanks in advance for any ideas to try and/or other forums to ask this in. thank you!
this is a project i am doing for school and will try to port to objective-c after i finish the C# portion.
(Last edited by zanyterp; Jun 15, 2005 at 10:18 AM.
(Reason:thought of more information to add & more descriptive title))
|
|
some people are like slinkys: they don't do much, but are fun to push down stairs.
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status:
Offline
|
|
Originally Posted by zanyterp
I am trying to connect to an access database via c#/.net. i am able to connect to the database and write (not the correct information, but something). i am trying to get numbers from combo boxes and insert them into a table. the code i am using to try and get the combo box value from is being posted into the table; not the value itself. i am also getting a type mismatch on the average field and the avg variable. the average field is set to the numeric type and avg is a double.
Code:
sql = "INSERT INTO TeacherEval ([Interesting, Useful, Relevant], [Appropriate Pace], [Clear & Understandable], [Effective Teaching Aids], [Combined Theory & application], [Used Examples, Demos, Hands-on], [Knew Subject Matter], [Organized Lessons], [Created Mutual Respect], [Encouraged Participation], [Prepared, Started, Ended, on Time], [Fair & Timely Grading], [Positive Attitude & Appearance], [Enforced Policies Consistently], [Overall Evaluation], [Average])" +
"values (':combo1.Text', ':combo2.Text', ':combo3.Text', ':combo4.Text', ':combo5.Text', ':combo6.Text', ':combo7.Text', ':combo8.Text', ':combo9.Text', ':combo10.Text', ':combo11.Text', ':comb12.Text', ':combo13.Text', ':combo14.Text', ':combo15.Text', 'avg')";
sql is a string variable that is used to be set as the oleDbCommand() for the sql query into the database. the text that is being sent to the database, when i don't include average and avg, is the string i am using to try and get the value from the combo box.
thanks in advance for any ideas to try and/or other forums to ask this in. thank you!
this is a project i am doing for school and will try to port to objective-c after i finish the C# portion.
i don't know if anyone is interested or will benefit, but i did find out what was wrong with my code and though i would post the answer in case it helps anyone else out in the future (and if i can get hold of one of the eMacs at school i will post an update on the port when i am able to do that on if the same code will work)
the revised code is:
Code:
sql = "INSERT INTO TeacherEval ([Interesting, Useful, Relevant], [Appropriate Pace], [Clear & Understandable], [Effective Teaching Aids], [Combined Theory & application], [Used Examples, Demos, Hands-on], [Knew Subject Matter], [Organized Lessons], [Created Mutual Respect], [Encouraged Participation], [Prepared, Started, Ended, on Time], [Fair & Timely Grading], [Positive Attitude & Appearance], [Enforced Policies Consistently], [Overall Evaluation], [Average])" +
"values ('"+ combo1.Text +"', '" +combo2.Text+ "', '"+ combo3.Text +"', '" + combo4.Text +"', '"+ combo5.Text +"', '"+ combo6.Text +"', '"+ combo7.Text +"', '"+ combo8.Text +"', '"+ combo9.Text +"', '"+ combo10.Text +"', '"+ combo11.Text +"', '"+ combo12.Text +"', '"+ combo13.Text +"', '"+ combo14.Text +"', '"+ combo15.Text +"', "+ avg +")";
it appears that each element has to be added separately(?) and enclosed in '+' in order to play nice.
thank you.
|
|
some people are like slinkys: they don't do much, but are fun to push down stairs.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|