Problems with UPDATE
am 05.06.2007 11:23:04 von davidgordon
Hi,
I am trying to create a simple ASP web counter for my site, but seem
to have an error somewhere ???
I am connecting to a MySQL server (works fine)
hit-marker = Varchar
hit_date = Date
hit-browser = Varchar
<%
marker = 1
browser = Request.ServerVariables("http_user_agent")
hitdate = date()
yy = Year(hitdate)
mm = Month(hitdate)
dd = Day(hitdate)
S_date = yy & "/" & mm & "/" & dd
Set adoDataConn = Server.CreateObject("ADODB.Connection")
adoDataConn.Open conn_string
uSQL = "INSERT INTO Webwiz (hit-marker, hit_date, hit-browser) VALUES
('" & marker & "'," & S_date & ",'" & browser & "');"
set RS = adoDataConn.Execute(uSQL)
%>
I keep getting the following error:
------------------------------------------------------------ ----
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[MySQL][ODBC 3.51 Driver][mysqld-4.1.22-standard]You have an error in
your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '-marker, hit_date,
hit-browser) VALUES ('1',2007/6/5,'Mozilla/5.0 (Windows; U; W' at line
1
/hitwise.asp, line 20
________________________________________
What am I doing wrong ?
Any advise would be a great help :-)
Thanks in advance
David
Re: Problems with UPDATE
am 05.06.2007 12:46:37 von reb01501
David wrote:
> Hi,
>
> I am trying to create a simple ASP web counter for my site, but seem
> to have an error somewhere ???
> I am connecting to a MySQL server (works fine)
>
> hit-marker = Varchar
> hit_date = Date
> hit-browser = Varchar
>
>
> <%
>
> marker = 1
>
> browser = Request.ServerVariables("http_user_agent")
>
> hitdate = date()
> yy = Year(hitdate)
> mm = Month(hitdate)
> dd = Day(hitdate)
> S_date = yy & "/" & mm & "/" & dd
>
> Set adoDataConn = Server.CreateObject("ADODB.Connection")
> adoDataConn.Open conn_string
>
> uSQL = "INSERT INTO Webwiz (hit-marker, hit_date, hit-browser) VALUES
> ('" & marker & "'," & S_date & ",'" & browser & "');"
> set RS = adoDataConn.Execute(uSQL)
>
> %>
>
> I keep getting the following error:
>
> ------------------------------------------------------------ ----
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>
> [MySQL][ODBC 3.51 Driver][mysqld-4.1.22-standard]You have an error in
> your SQL syntax; check the manual that corresponds to your MySQL
> server version for the right syntax to use near '-marker, hit_date,
> hit-browser) VALUES ('1',2007/6/5,'Mozilla/5.0 (Windows; U; W' at line
> 1
>
> /hitwise.asp, line 20
>
> ________________________________________
>
> What am I doing wrong ?
> Any advise would be a great help :-)
>
I don't use MySQL, but I suspect you are passing the date incorrectly. To
the query parser 2006/6/5 looks like 2006 divided by 6 divided by 5, a
formula which is unlikely to correspond to a valid date value. Look up in
the MySQL documentation to see how date literals are supposed to be used in
sql statements. In SQL Server, they have to be delimited with apostrophes.
If that's not it, then I suspect the query parser may be getting confused by
the hyphens in the column names. Can you change the names of those columns?
If so, that would be my course of action. If not, then you will need to
delimit the column names to tell the parser to accept them as they are. In
SQL Server, I would use brackets [hit-marker] . Check the MySQL
documentation to verify what delimiters should be used for identifiers.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: Problems with UPDATE
am 05.06.2007 15:56:55 von Adrienne Boswell
Gazing into my crystal ball I observed "Bob Barrows [MVP]"
writing in
news:OM9C761pHHA.3644@TK2MSFTNGP02.phx.gbl:
> David wrote:
>> Hi,
>>
>> I am trying to create a simple ASP web counter for my site, but seem
>> to have an error somewhere ???
>> I am connecting to a MySQL server (works fine)
>>
>> hit-marker = Varchar
>> hit_date = Date
>> hit-browser = Varchar
>>
>>
>> <%
>>
>> marker = 1
>>
>> browser = Request.ServerVariables("http_user_agent")
>>
>> hitdate = date()
>> yy = Year(hitdate)
>> mm = Month(hitdate)
>> dd = Day(hitdate)
>> S_date = yy & "/" & mm & "/" & dd
>>
>> Set adoDataConn = Server.CreateObject("ADODB.Connection")
>> adoDataConn.Open conn_string
>>
>> uSQL = "INSERT INTO Webwiz (hit-marker, hit_date, hit-browser) VALUES
>> ('" & marker & "'," & S_date & ",'" & browser & "');"
>> set RS = adoDataConn.Execute(uSQL)
>>
>> %>
>>
>> I keep getting the following error:
>>
>> ------------------------------------------------------------ ----
>>
>> Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>>
>> [MySQL][ODBC 3.51 Driver][mysqld-4.1.22-standard]You have an error in
>> your SQL syntax; check the manual that corresponds to your MySQL
>> server version for the right syntax to use near '-marker, hit_date,
>> hit-browser) VALUES ('1',2007/6/5,'Mozilla/5.0 (Windows; U; W' at
>> line 1
>>
>> /hitwise.asp, line 20
>>
>> ________________________________________
>>
>> What am I doing wrong ?
>> Any advise would be a great help :-)
>>
> I don't use MySQL, but I suspect you are passing the date incorrectly.
> To the query parser 2006/6/5 looks like 2006 divided by 6 divided by
> 5, a formula which is unlikely to correspond to a valid date value.
> Look up in the MySQL documentation to see how date literals are
> supposed to be used in sql statements. In SQL Server, they have to be
> delimited with apostrophes.
Dates in MySQL: 'MM-DD-YYYY'
>
> If that's not it, then I suspect the query parser may be getting
> confused by the hyphens in the column names. Can you change the names
> of those columns? If so, that would be my course of action. If not,
> then you will need to delimit the column names to tell the parser to
> accept them as they are. In SQL Server, I would use brackets
> [hit-marker] . Check the MySQL documentation to verify what delimiters
> should be used for identifiers.
>
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share