Link to home
Start Free TrialLog in
Avatar of Graeme McGilvray
Graeme McGilvrayFlag for Australia

asked on

Issues with Insert statement

Hi there! I am having issues with this particular insert statement.

for some reason is wont write it to the database nor shows an error either

I thought the IF statement prior to this was not working, however I have tested it and it works fine, just this below doesnt...

oConn.Execute("INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_curr,session_rate) VALUES("&Session.SessionID&",'"&SubDomain("brand_options.brand_ID")&"','"&RemoteIP&"','"&CityLoc&"','"&CountryLoc&"',"&Timezone&",'"&Now()&"','"&ClientCurr&"',"&ClientConvert&")")

Open in new window


Please ask questions away, just need to figure this out

Thanks
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Please post datatypes. I think brand_ID is int
oConn.Execute("INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_curr,session_rate) VALUES("&Session.SessionID&","&SubDomain("brand_options.brand_ID")&",'"&RemoteIP&"','"&CityLoc&"','"&CountryLoc&"',"&Timezone&",'"&Now()&"','"&ClientCurr&"',"&ClientConvert&")")

Open in new window

quick try:

oConn.Execute("INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_curr,session_rate) VALUES("&Session.SessionID&",'"&SubDomain("brand_options.brand_ID")&"','"&RemoteIP&"','"&CityLoc&"','"&CountryLoc&"',"&Timezone&", Now() ,'"&ClientCurr&"',"&ClientConvert&")")

Open in new window


make sure if your field is a char field, we need to encapsulate the value with single quotes
oConn.Execute("INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_curr,session_rate) VALUES("& Session.SessionID & "," & SubDomain("brand_options.brand_ID") & ",'" & RemoteIP & "','" & CityLoc & "','" & CountryLoc & "'," & Timezone & ",'" & Now() & "','" & ClientCurr & "'," & ClientConvert & ")")

Open in new window

Avatar of Graeme McGilvray

ASKER

Hi Shaun, Brand_ID is char

Ryan, tried that, still no joy
-yeah gone thru them all prior found some single quotes in timezone where that is a number... was fixed then posted this question as it is still not working :(
@Graeme

try to response out the SQL so that we can verify that. also make sure you do not have single quote in your insert values? if yes then you need to double the single quote to escape the value.

SQL = "INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_curr,session_rate) VALUES("&Session.SessionID&",'"&SubDomain("brand_options.brand_ID")&"','"&RemoteIP&"','"&CityLoc&"','"&CountryLoc&"',"&Timezone&",'"&Now()&"','"&ClientCurr&"',"&ClientConvert&")"
Response.write SQL
Response.end
oConn.Execute(SQL)

Open in new window

INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_curr,session_rate) VALUES(469735566,'GPT','49.196.168.130','Perth','AU',8,'16/01/2017 10:08:49','AUD',1.337704)"

Open in new window

As a new session you can see the output for yourself

dev.gptouring.com.au

Scroll up to see the new session information
INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_curr,session_rate) VALUES(469735566,'GPT','49.196.168.130','Perth','AU',8,'16/01/2017 10:08:49','AUD',1.337704)"

looks ok.... what if you manually execute this insert statement into your database (Access if not wrong?), what error did you get here?

you may also manually test this and see if you got any error?

INSERT INTO site_sessions(session_ID,brand_ID,session_IP,session_geoCity,session_geoCountry,session_timezone,session_date,session_curr,session_rate) VALUES(469735566,'GPT','49.196.168.130','Perth','AU',8, now() ,'AUD',1.337704)

Open in new window

Hi Ryan, tried my output and your output, no errors... no insert done

Question...
-Is there a max amount of records that can be held in a table? currently in that table there is 9062
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
maybe you have error handling turned off, put the following line right above the insert statement:

on error goto 0

this will reset it in case you have on error resume next somewhere on your page
Have gone thru and found 2 letters back to front on my end :/

Thanks for the debug!