I have a problem that i cant understand since I have use the same code before and the same database.
I get an error message telling me "System.NullReferenceException: 'Object reference has not been given to an instance of an object.'
I have tried to find solutions, but nothing is working. What am I doing wrong?
I would very much appreciate you proffessional view on this.
The code where I get the problem looks like this:
Row 155: Dim DBCon As SqlConnection = New SqlConnection(" Data Source = DESKTOP - 97B62HO;Initial Catalog=gameBase;User ID=Leffeq;Password=Password1;")
I can connect to the database through the SQL Server Object Explorer with the same credentials.
System.NullReferenceException: 'Object reference has not been given to an instance of an object.'
at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
at System.Data.SqlClient.SqlConnection..ctor(String connectionString, SqlCredential credential)
at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at myNewWorld.Form1.Form1_Painta(Object sender, PaintEventArgs e)
at C:\Users\dator\source\repos\myNewWorld\Form1.vb:row 155
at System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Form.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)