Καλημερα,
Σας παραθέτω τμήμα του κώδικα το οποίο τρέχω καθώς και το σφάλμα που μου εμφανιζει.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim queryString As String = _
"SELECT oCode FROM ..... WHERE (.... Like '.......')"
Dim ds As DataSet1 = GetData(queryString)
If (ds.Tables.Count > 0) Then
AuthorsGridView.DataSource = ds
AuthorsGridView.DataBind()
Else
Message.Text = "ΑΔΥΝΑΜΙΑ ΣΥΝΔΕΣΗΣ ΜΕ ΤΗ ΒΑΣΗ ΔΕΔΟΜΕΝΩΝ."
End If
End If
End Sub
Function GetData(ByVal queryString As String) As DataSet1
Dim connectionString As String
connectionString = ConfigurationManager.ConnectionStrings("DBConString").ConnectionString
Dim ds As New DataSet1()
Try
Dim connection As New SqlConnection(connectionString)
Dim adapter As New SqlDataAdapter(queryString, connection)
adapter.Fill(ds)
Catch ex As Exception
Message.Text = "ΑΔΥΝΑΜΙΑ ΣΥΝΔΕΣΗΣ ΜΕ ΤΗ ΒΑΣΗ ΔΕΔΟΜΕΝΩΝ."
End Try
Return ds
End Function
---------------------------------------------
και το σφαλμα:
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: .9em}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
Object reference not set to an instance of an object.
Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code.
Exception Details:
System.NullReferenceException: Object reference not set to an instance of an
object.
Source Error:
Line 34: Dim connectionString As String Line 35: Line 36: connectionString = ConfigurationManager.ConnectionStrings("DBConString").ConnectionString Line 37: Line 38: Dim ds As New DataSet1() |