|
-
Jul 10th, 2005, 02:50 PM
#1
Thread Starter
Frenzied Member
Problem in INSERT [RESOLVED]
Hello everybody,
I am facing a problem in inserting record in Access database. Here is the short code snippet, which gives exception "Syntax error in INSERT INTO statement", however if I print the query by uncommenting the Response.Write line and copy the query and paste it in access and run, it runs well.
VB Code:
' Insert
Set Rs = Conn.Execute("SELECT [User].[UserName] FROM [User] WHERE [User].[UserName] = '" & UserName & "' AND [User].[IsDeleted] = False")
If Rs.EOF Then
Dim InsertSql
InsertSql = "INSERT INTO [User] (Name,UserName,Password,IsAdmin,IsSupervisor,IsDeleted) VALUES('" & FullName & "','" & UserName & "','" & Password & "'," & IsAdmin & "," & IsSupervisor & ",False)"
'Response.Write(InsertSql)
'Response.End
Cmd.ActiveConnection = Conn
Cmd.CommandText = InsertSql
Cmd.Execute()
'Set Rs = Conn.Execute(InsertSql)
Response.Redirect("User.asp?Message=UserAdded")
Else
Response.Redirect("User.asp?Message=UserFound")
End If
Last edited by usamaalam; Jul 10th, 2005 at 03:18 PM.
Reason: RESVOLED
-
Jul 10th, 2005, 02:52 PM
#2
Re: Problem in INSERT
NAME, USERNAME and PASSWORD are truly bad choices for column names.
Place them all in []-brackets - they are most likely reserved keywords (check the link at the bottom of my signature)...
Some providers handle it better then others - the ACCESS tool probably "wraps them in []-brackets" behind the scenes for you...
-
Jul 10th, 2005, 02:55 PM
#3
Re: Problem in INSERT
Also, the tablename "User" may cause issues later down the road too.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 10th, 2005, 02:57 PM
#4
Re: Problem in INSERT
I had a colleage that decided to name a MS SQL Server table in an odd way - I think it started with a number.
He thought he would be able to always wrap it in []-brackets and live with it.
One day he discovered a bug in ENTERPRISE MANAGER - I think it would not backup the table since the name was not valid. Since he could not control the "process" in EM that did this, he was lost...
Just not worth it.
-
Jul 10th, 2005, 03:03 PM
#5
Re: Problem in INSERT
Colleges do that with their workstations. They give them serial numbers as names. After a few humdred systems you dont
know what is what.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 10th, 2005, 03:09 PM
#6
Thread Starter
Frenzied Member
Re: Problem in INSERT
Thanks a lot. I put the column names in brackets and the probem is resolved.
-
Jul 10th, 2005, 03:12 PM
#7
Re: Problem in INSERT
 Originally Posted by RobDog888
Colleges do that with their workstations. They give them serial numbers as names. After a few humdred systems you dont
know what is what. 
I can't spell today? Or am I just not understood?
Colleague - as in associate - another developer I work with at a customer site...
College - not what I meant
-
Jul 10th, 2005, 03:27 PM
#8
Re: Problem in INSERT [RESOLVED]
No, I understood you but was giving some insight to what I had to deal with at a particular college (what I mean ) backing up the notion of
naming systems/servers with numbers is
not that great an idea.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 10th, 2005, 05:07 PM
#9
Re: Problem in INSERT [RESOLVED]
 Originally Posted by RobDog888
No, I understood you but was giving some insight to what I had to deal with at a particular college (what I mean ) backing up the notion of
naming systems/servers with numbers is
not that great an idea. 
Oh - I get it now...
I'm from the days before networks where known - big old single CPU mainframe boxes - then clustered systems...
Then Ethernet and DECNET came into our world - we went nuts - starting naming things after stars, planets, disney characters, old star trek stuff...
Now - seems the hardware guy who installed my SBS and a Server 2003 system at one of my main customer sites decided on bland names like SERVER01, SERVER02, SERVER03 and SERVER04. When I RDP into that other system all kinds of reference problems pop up - he should have asked what we like to name them!
-
Jul 10th, 2005, 05:32 PM
#10
Re: Problem in INSERT [RESOLVED]
I just came accross a tweak that changes the My Computer desktop icon name to "Username loged on to machinename". Let me
see if I can find it again. 
Should help when logging into several desktops after another etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 10th, 2005, 05:42 PM
#11
Re: Problem in INSERT [RESOLVED]
The registry tweak can be found here.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|