Question:
OleDb Exception Unhandled - Vb.Net?
Pradeep
2013-06-27 05:40:42 UTC
I created a new table creating app in vb. Since im new to DB programming, I always get frustrated when it comes to errors. Here is the error i couldn't solve:

Imports System.Data.OleDb

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sql As String = "CREATE TABLE Employee (Name,Address);"
Dim cn As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=D:\\Users\\HaCkEr\\My Documents\\Employees.accdb;"

Dim conn As OleDbConnection = New OleDbConnection(cn)

Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)


conn.Open()
cmd.ExecuteNonQuery()
conn.Close()

End Sub
End Class

and here is the detailed exception

System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217900
Message=Syntax error in field definition.
Source=Microsoft Office Access Database Engine
StackTrace:
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
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 Employees.Form1.Button1_Click(Object sender, EventArgs e) in D:\Users\Nandhakishore\AppData\Local\Temporary Projects\Employees\Form1.vb:line 15
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(IntPtr 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 Employees.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Help me please...
Three answers:
The Wanderer
2013-06-27 06:16:48 UTC
Looks like there might be something wrong with your 'CREATE TABLE' SQL... should define the column data types, here is an example from the MSDN site...

"CREATE TABLE ThisTable (FirstName CHAR, LastName CHAR);"



here is a link that might be helpful...

http://msdn.microsoft.com/en-us/library/office/bb177893%28v=office.12%29.aspx



try changing you SQL

from

CREATE TABLE Employee (Name,Address);

to

CREATE TABLE Employee (Name CHAR,Address CHAR);
?
2016-12-18 22:46:16 UTC
Oledb Vb.net
2016-12-14 14:08:48 UTC
in spite of the actual undeniable fact that it feels precisely the comparable with the aid of fact the final 5 CoD titles and that the snap shots look fairly undesirable, i visit assert that it somewhat is a sturdy recreation. large? hardly ever. remarkable? Lol, no. solid? definite. the ingredient that CoD Blops 2 did proper is fairly plenty the single ingredient that the CoD video games constantly get proper, and that's packing tonnes of content textile into the recreation. regardless of in case you haven't any longer have been given on line, there is SOO plenty to do. marketing campaign with distinctive paths, zombies with the capacity to splitscreen it with a mate and multiplayer with the capacity to splitscreen it with as much as 3 friends, or in simple terms bypass in on your very own and verse as much as 9 pc-controlled gamers, or the two on the comparable time. To sum issues up, in case you enjoyed the previous call of accountability titles, then opportunities are high you will in all probability savor this one, if no longer, bypass to a pal's abode and verify it out.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...