473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Object reference


"Dmension" <df****@napcosecurity.com> wrote in message news:...
Here is a snippet of my code. At "SDA.SelectCommand.CommandText = "Select
(*) FROM Badge " I get an error message that says "Additional information:
Object reference not set to an instance of an object"

Any help would be appreciated..

Private Sub btnfill_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnfill.Click

'Dim Waitfrm As New frmPerload

Dim SDA As New SqlDataAdapter

Dim SCN As New SqlConnection

Dim SDS As New DataSet

'Waitfrm.Show()

'System.Threading.Thread.Sleep(5000)

'Waitfrm.Close()

SDS.Clear()

SbarPanel1.Text = "Loading Personnel"

SCN.ConnectionString = ("Persist Security Info=False;User
ID=cic;Password=cic;Initial Catalog=AG30000;Data Source=ENGSQEG246A;")

SCN.Open()

MessageBox.Show("connection is open")

SDA.SelectCommand.CommandText = "Select (*) FROM Badge "

SDA.SelectCommand.Connection = SCN

SDA.Fill(SDS)

lstBoxPersonnel.DataSource = SDS

lstBoxPersonnel.DisplayMember = "Badge"

SbarPanel2.Text = "Number of Records" +
(SDS.Tables(0).Rows.Count.ToString)

'SCN.Close()'

End Sub

Nov 21 '05 #1
2 1067

Jan. 11, 2005

When you create a new dataadapter, it does not create a blank
DA.SelectCommand object. You must create a SqlCommand and then assign it to
the .SelectCommand property, before you can configure the DA's functioning
through the .SelectCommand.Methods. So:

Private Sub btnfill_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnfill.Click

'Dim Waitfrm As New frmPerload

Dim SDA As New SqlDataAdapter

Dim SCN As New SqlConnection

Dim SDS As New DataSet

'Waitfrm.Show()

'System.Threading.Thread.Sleep(5000)

'Waitfrm.Close()

SDS.Clear()

SbarPanel1.Text = "Loading Personnel"

SCN.ConnectionString = ("Persist Security Info=False;User
ID=cic;Password=cic;Initial Catalog=AG30000;Data Source=ENGSQEG246A;")

SCN.Open()

MessageBox.Show("connection is open")
*** DIM selectcom as new sqlcommand
SDA.SelectCommand = selectcom 'Now you can configure it on the
next line SDA.SelectCommand.CommandText = "Select (*) FROM Badge "

SDA.SelectCommand.Connection = SCN

SDA.Fill(SDS)

lstBoxPersonnel.DataSource = SDS

lstBoxPersonnel.DisplayMember = "Badge"

SbarPanel2.Text = "Number of Records" +
(SDS.Tables(0).Rows.Count.ToString)

'SCN.Close()'

End Sub

I hope this will solve your problem! Have a great day! :)
Joseph MCAD
"Dmension" wrote:

"Dmension" <df****@napcosecurity.com> wrote in message news:...
Here is a snippet of my code. At "SDA.SelectCommand.CommandText = "Select
(*) FROM Badge " I get an error message that says "Additional information:
Object reference not set to an instance of an object"

Any help would be appreciated..

Private Sub btnfill_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnfill.Click

'Dim Waitfrm As New frmPerload

Dim SDA As New SqlDataAdapter

Dim SCN As New SqlConnection

Dim SDS As New DataSet

'Waitfrm.Show()

'System.Threading.Thread.Sleep(5000)

'Waitfrm.Close()

SDS.Clear()

SbarPanel1.Text = "Loading Personnel"

SCN.ConnectionString = ("Persist Security Info=False;User
ID=cic;Password=cic;Initial Catalog=AG30000;Data Source=ENGSQEG246A;")

SCN.Open()

MessageBox.Show("connection is open")

SDA.SelectCommand.CommandText = "Select (*) FROM Badge "

SDA.SelectCommand.Connection = SCN

SDA.Fill(SDS)

lstBoxPersonnel.DataSource = SDS

lstBoxPersonnel.DisplayMember = "Badge"

SbarPanel2.Text = "Number of Records" +
(SDS.Tables(0).Rows.Count.ToString)

'SCN.Close()'

End Sub


Nov 21 '05 #2
THanks Joseph,
Minutes after I sent this I noticed that I did not create a SQLcommand
therefore I cound not execute a command string.
"Joseph MCAD" <Jo********@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...

Jan. 11, 2005

When you create a new dataadapter, it does not create a blank
DA.SelectCommand object. You must create a SqlCommand and then assign it
to
the .SelectCommand property, before you can configure the DA's functioning
through the .SelectCommand.Methods. So:

Private Sub btnfill_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnfill.Click

'Dim Waitfrm As New frmPerload

Dim SDA As New SqlDataAdapter

Dim SCN As New SqlConnection

Dim SDS As New DataSet

'Waitfrm.Show()

'System.Threading.Thread.Sleep(5000)

'Waitfrm.Close()

SDS.Clear()

SbarPanel1.Text = "Loading Personnel"

SCN.ConnectionString = ("Persist Security Info=False;User
ID=cic;Password=cic;Initial Catalog=AG30000;Data Source=ENGSQEG246A;")

SCN.Open()

MessageBox.Show("connection is open")

*** DIM selectcom as new sqlcommand
SDA.SelectCommand = selectcom 'Now you can configure it on the
next line
SDA.SelectCommand.CommandText = "Select (*) FROM Badge "

SDA.SelectCommand.Connection = SCN

SDA.Fill(SDS)

lstBoxPersonnel.DataSource = SDS

lstBoxPersonnel.DisplayMember = "Badge"

SbarPanel2.Text = "Number of Records" +
(SDS.Tables(0).Rows.Count.ToString)

'SCN.Close()'

End Sub


I hope this will solve your problem! Have a great day! :)
Joseph MCAD
"Dmension" wrote:

"Dmension" <df****@napcosecurity.com> wrote in message news:...
> Here is a snippet of my code. At "SDA.SelectCommand.CommandText =
> "Select
> (*) FROM Badge " I get an error message that says "Additional
> information:
> Object reference not set to an instance of an object"
>
> Any help would be appreciated..
>
>
>
> Private Sub btnfill_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnfill.Click
>
> 'Dim Waitfrm As New frmPerload
>
> Dim SDA As New SqlDataAdapter
>
> Dim SCN As New SqlConnection
>
> Dim SDS As New DataSet
>
> 'Waitfrm.Show()
>
> 'System.Threading.Thread.Sleep(5000)
>
> 'Waitfrm.Close()
>
> SDS.Clear()
>
> SbarPanel1.Text = "Loading Personnel"
>
> SCN.ConnectionString = ("Persist Security Info=False;User
> ID=cic;Password=cic;Initial Catalog=AG30000;Data Source=ENGSQEG246A;")
>
> SCN.Open()
>
> MessageBox.Show("connection is open")
>
> SDA.SelectCommand.CommandText = "Select (*) FROM Badge "
>
> SDA.SelectCommand.Connection = SCN
>
> SDA.Fill(SDS)
>
> lstBoxPersonnel.DataSource = SDS
>
> lstBoxPersonnel.DisplayMember = "Badge"
>
> SbarPanel2.Text = "Number of Records" +
> (SDS.Tables(0).Rows.Count.ToString)
>
> 'SCN.Close()'
>
> End Sub
>
>


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris S. | last post by:
I'm trying to make a graphical editor and browser for Pickled files. One aspect I'm not sure about is how to detect multiple references to the same data. For instance, say I had the Pickled...
28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
29
by: web1110 | last post by:
If I have 2 variables, A and B, referencing the same object and then do a A.Dispose(), what happens to B?
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
16
by: anonymous.user0 | last post by:
The way I understand it, if I have an object Listener that has registered as a listener for some event Event that's produced by an object Emitter, as long as Emitter is still allocated Listener...
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.