|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi, i hope u ppl will help me, i have made a class connectioncontrol and there is a method in that class namely sql_command(ByVal qq As String) but when i pass a string to this method i get the above mentionaed error
the code is Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cc As ConnectionControl Dim queryString As String queryString = "select * from t_category" cc.sql_command(queryString) DataGrid1.DataSource = cc.myCommand.ExecuteReader(CommandBehavior.CloseConnection) DataGrid1.DataBind() cc.connection_close() End Sub Public Class ConnectionControl Dim myConnectionString As String Dim queryString As String Public myConnection As New SqlConnection() Public myCommand As New SqlCommand() Public Sub sql_command(ByVal qq As String) myConnectionString = "server=(local);database=e-auction;trusted_connection=true" myConnection.ConnectionString = myConnectionString myConnection.Open() myCommand.CommandText = qq myCommand.Connection = myConnection End Sub Public Sub connection_close() myConnection.Close() End Sub End Class |
|
#2
|
|||
|
|||
|
I don't code in VB.NET, but it doesn't look like you instantiated the ConnectionControl object. Try using the new keyword.
Code:
Dim cc As New ConnectionControl() |
|
#3
|
|||
|
|||
|
thanks
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > .Net Development > Object reference not set to an instance of an object |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|