itzkhurram
New member
- Joined
- Oct 9, 2007
- Messages
- 2
- Programming Experience
- 1-3
I want simple connect VB.net windos application form to SQL Server 2000 Database(pubs) but error msg appear every time when i run the form
Error indicate the line conn.open()
Error:
Error indicate the line conn.open()
Error:
An unhandled exception of type 'System.NullReferenceException' occurred in system.data.dll
Additional information: Object reference not set to an instance of an object.
VB.NET:
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim conn As SqlConnection
#Region " Windows Form Designer generated code "
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
conn = New SqlConnection("server=(local);database=pubs;uid=sa;pwd=sa;")
conn.Open() ******* there is error
End Sub
End Class
Last edited by a moderator: