Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

[2005] Connection to DB not working properly, Code/image inc.

attached is the errors im receiving ( cut down to size for file size reasons) i need to figure out why... the code and everythign is showing there as well, can someone help me please?
[183 byte] By [vchatlive] at [2007-11-11 10:21:18]
# 1 Re: [2005] Connection to DB not working properly, Code/image inc.
Errors:

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="MySql.Data"
StackTrace:
at MySql.Data.MySqlClient.NativeDriver.get_SupportsBatch()
at MySql.Data.MySqlClient.Statement.TokenizeSql(String sql)
at MySql.Data.MySqlClient.Statement.BindParameters()
at MySql.Data.MySqlClient.PreparableStatement.Execute(MySqlParameterCollection parameters)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.Driver.Configure(MySqlConnection connection)
at MySql.Data.MySqlClient.NativeDriver.Configure(MySqlConnection connection)
at MySql.Data.MySqlClient.MySqlConnection.Open()
at VCLICS.frmLogin.cmdLogin_Click(Object sender, EventArgs e) in C:\Documents and Settings\Eric\My Documents\Visual Studio 2005\Projects\VCLICS\VCLICS\frmLogin.vb:line 12
at System.Windows.Forms.Control.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.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 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at VCLICS.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
vchatlive at 2007-11-11 20:48:05 >
# 2 Re: [2005] Connection to DB not working properly, Code/image inc.
edid all the code, got this error

A first chance exception of type 'System.NullReferenceException' occurred in MySql.Data.dll

heres the code.

Imports MySql.Data.MySqlClient
Public Class frmLogin
Dim conn As MySqlConnection
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
conn = New MySqlConnection()
conn.ConnectionString = "server=x.x.x.x; user id=xxx; password=xxx; database=xxx"
Try
conn.Open()
MessageBox.Show("Connection Opened Successfully")
conn.Close()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
Finally
conn.Dispose()
End Try

End Sub
End Class

obviously iv'e X'd out the serverinfo for security reasons, and the highlited issue is conn.open() it says "NullReferenceException Unhandled" in a little popup window.

ANY IDEAS? this is driving me nuts
vchatlive at 2007-11-11 20:49:13 >
# 3 Re: [2005] Connection to DB not working properly, Code/image inc.
try this one instead

'This declaration automatically opens the connection
dim conn as New MySqlConnection("server=xxx;user id=xxx;password=xxx;datavase=xxx")

if conn.State = ConnectionState.Open then
msgbox("Connection Open")
else
msgbox("Connection Failed")
end if
kenvil at 2007-11-11 20:50:12 >