12-07-15, 08:37 AM
الاخوة الكرام السلام عليكم ورحمة الله انا مبتدي في ال vb.net احاول ربطه مع قاعدة بيانات SQL server 2005 حسب برنامج تعليمي ولكن واجهتني هذه المشكله
نامل المساعدة في معرفة السبب وتصحيحه او الافادة في عدم الاتصال بقاعدة البيانات
Imports System.Data.SqlClient
Public Class Class1
Public Shared sqlcon As SqlConnection
End Class
----------------------------------------------------------------
Module Module1
Public sqfind As New Class1
End Module
---------------------------------------------------------------
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Class1.sqlcon.ConnectionString = "data source=HP\SQLEXPRESS;Initial catalog=POSDB;Integrated security=True"
MsgBox("تم الاتصال بنجاح", MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
Public Class Class1
Public Shared sqlcon As SqlConnection
End Class
----------------------------------------------------------------
Module Module1
Public sqfind As New Class1
End Module
---------------------------------------------------------------
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Class1.sqlcon.ConnectionString = "data source=HP\SQLEXPRESS;Initial catalog=POSDB;Integrated security=True"
MsgBox("تم الاتصال بنجاح", MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
إقتباس :هذه الرسالة التى تظهر في التنبيه : object reference reference not set to an instance of an object
جزاكم الله كل خر