.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 25th, 2003, 04:53 AM
vick vick is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 14 vick User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Object reference not set to an instance of an object

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

Reply With Quote
  #2  
Old October 26th, 2003, 11:30 PM
sano sano is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Redmond, WA
Posts: 218 sano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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()

Reply With Quote
  #3  
Old October 27th, 2003, 01:57 AM
vick vick is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 14 vick User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Object reference not set to an instance of an object


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT