Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More SQL assistance needed...

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
0
0
US
[tt]
Here's what I'm trying to do in my SQL database.

I need to format a unique numbering system for this site which will look like this

Unique Account Number
Year - Month - User Initials & 001



Here's what I have done so far
<%

curDate = Now()
pyy = Year(curDate)
pmm = Month(curDate)
pui = request.cookies(&quot;initials&quot;)
if len(bidmm) = 1 Then
bidmm = &quot;0&quot; & bidmm
end if

Dim MyRs
Set MyRs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
SQL = &quot;Select accnumber from tbl Where accnumber like '&quot; & pyy & pmm & &quot;%&quot; and initials = &quot; pui
MyRs.open SQL, &quot;DSN=proposal&quot;

if MyRs.eof or MyRs.bof
fullaccnumber = pyy & pmm & &quot;001&quot;
else
fullaccnumber = MyRs + 1
end if
response.write fullaccnumber
%>



Error I'm getting and can't find it
Error Type:
Microsoft VBScript compilation
Unterminated string constant
Line 17
Line 17 = SQL = &quot;Select accnumber from tbl Where accnumber like '&quot; & pyy & pmm & &quot;%&quot; and initials = &quot; pui




[sup]
T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
logo.gif

[/sup]
 
SQL = &quot;Select accnumber from tbl Where accnumber like '&quot; & pyy & pmm & &quot;%&quot; and initials = &quot; pui

count the quotes matching single to double. [wink]

_________________________________________________________
for the best results to your questions: FAQ333-2924
[sub]01001111 01101110 01110000 01101110 01110100[/sub]
onpnt2.gif
[sup] [/sub]
 
Here try this statement below copy and paste it and it will work.... But only if accunumber is not a string made by concatenating pyy, pmm and pui....


&quot;Select
accnumber
from
tbl
Where
accnumber like '%&quot; pyy & pmm & &quot;%'&quot;
& &quot;and initials = '&quot; & pui & &quot;'&quot;
 
[tt]I got it working yesterday. thanks guys

[sup]
T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
logo.gif

[/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top