Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > database connection

database connection
Thread Tools
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Jun 15, 2005, 02:55 AM
 
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
Reply With Quote
Jun 15, 2005, 11:52 PM
 
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.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:16 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2