msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HELP passing data into Access DB

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
frogman14



Joined: 04 Oct 2007
Posts: 1

PostPosted: Tue May 29, 2007 4:27 pm    Post subject: HELP passing data into Access DB Reply with quote

I am trying to pass data into an access DB using the syntax

Dim cmd As New OleDbCommand
cmd.Connection = conn
cmd.CommandText = "INSERT INTO entry ([save_date],
[save_time], subject, body) " & _
"VALUES ('" & txtDate.Text & "'," & _
"'" & txtTime.Text & "'," & _
"'" & txtSubject.Text & "'," & _
"'" & txtBody.Text & "'"
'"'" & Replace$(txtNotes.Text, """", """""") & "'," & _
'"'" & Replace$(txtMeaning.Text, """", """""") & "'"
cmd.ExecuteNonQuery()


I get an error OleDBException was unhandled.

Below are the details of the error.

System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217900
Message="Syntax error in INSERT INTO statement."
Source="Microsoft JET Database Engine"
StackTrace:
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Ministry_Journal.frmEntry.cmdSave_Click(Object sender,
EventArgs e) in C:\Documents and Settings\Tyler\My Documents
\Ministry_Journal\Ministry_Journal\Ministry_Journal\frmEntry.vb:line
46
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext
context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine)
at Ministry_Journal.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


What is wrong with my insert statement?

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Bob Butler



Joined: 04 Oct 2007
Posts: 1081

PostPosted: Tue May 29, 2007 5:07 pm    Post subject: Re: HELP passing data into Access DB Reply with quote

wrote in message @g4g2000hsf.googlegroups.com...
>I am trying to pass data into an access DB using the syntax
>
> Dim cmd As New OleDbCommand


--
You need to ask in a newsgroup with "dotnet" in the name. This group id for
VB 6.0 and earlier and does not include VB.Net or VB 200x.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group