Hi! I have this piece of code, I want to write the user input into db. The problem is that the variables are of multiple types, int and strings. What am I doing wrong/ I can t compile it.
I have hidden the server, user and other info. thx
the database insert statement should work exactly like it would in a sql connectivity tool to the database. You type integers in base 10 as strings in those:
insert into blah col 1 values 12345 where stuff
something like that, right? 12345 is just text when you do that.
your insert library call should do that same exact thing.
if it does not work, what I would do is print the sql statement that you sent to the DB and try to run it from your sql tool to see if it works there. You may also see the problem immediately when printed out.
some other stuff:
you may need to check that your connection worked differently.
you may need to wait until you have confirmed the connection, some DB take many MS to respond and you may be spamming the DB server, eg 'connect' and then 2 nanoseconds later query, and its still connecting so it fails out. So instead of 'if connect' you may want to say
while (!connect && sometimer < 2 seconds); //wait, wait, wait, ok connected
…
if (connect) //it either timed out or connected or errored at this point, right?
talking to other machines is tedious. You spend half your time waiting on them to get their act in gear, in my experience.