Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Local variable assAdapter already declared in block?

Reply
 
Old 07-22-2008   #1 (permalink)
bill


 
 

Local variable assAdapter already declared in block?

Now you can work on your naming conventions.

The @$$Adaptor sounds like something you use to get a colonoscopy and you
have an oversized or undersized butt. (ha ha).

...



"bill" <bill@xxxxxx> wrote in message
news:ubas75J7IHA.4108@xxxxxx
Quote:

> Oh man, I should have seen that. I comment out that lin, add the con to
> the second and it works perfectly. Thank you so much! You have been
> incredibly helpful and patient and I really appreciate it. I have learned
> allot!
> Thank you!
> Bill Bray
>
> "Jack Jackson" <jjackson@xxxxxx> wrote in message
> newskid841jv1v9t9r705clrbc5bphn5u8kgr@xxxxxx
Quote:

>> Sure. The message says it all. The DataAdapter's Select command,
>> which is built from the text you pass to the DataAdapter's
>> constructor, doesn't have any connection info.
>>
>> See my comments below.
>>
Quote:

>>>> assCmd = New OleDb.OleDbCommand( _
>>>> "SELECT * from tblAssets where asset_tag=?", Con)
>>>> assAdapter = New OleDbAdapter(assCmd)
>>
>> On Tue, 22 Jul 2008 18:05:09 -0600, "bill" <bill@xxxxxx>
>> wrote:
>>
Quote:

>>>Thank you again! That got it Though there is more now.... I get an
>>>error
>>>at "assAdapter.fill(assDT)" that says "fill: SelectCommand.Connection
>>>property has not been initialized? Do you see why?
>>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
>>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>>2008\IT_Assets.mdb")
>>
>> The following line creates an OleDbCommand without a connection
>> object.
>>
Quote:

>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>asset_tag=?")
>>>
>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>
>> The following line creates a DataAdapter from the OleDbCommand object
>> that doesn't have a connection object.
>>
Quote:

>>>assAdapter = New OleDb.OleDbDataAdapter(assCmd)
>>>
>>>'Dim assCmd As OleDb.OleDbCommand
>>
>> The following line creates a second command object with the same
>> select as the previous one, this time with a connection object. This
>> command object is never used. You should get rid of this line, and
>> add Con as a second parameter to the previous OleDbCommand.
>>
Quote:

>>>assCmd = New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>asset_tag=?",
>>>Con)
>>>
>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>cboAsset.Text
>>>
>>>Dim assDT As New DataTable
>>>
>>>'Need to initialize the dataAdapter here
>>>
>>>'Release the instances of the above objects
>>>
>>>assAdapter.Fill(assDT)
>>>
>>>'assAdapter.Dispose()
>>>
>>>Me.DataGridView1.DataSource = assDT
>>>
>>>End If
>>>
>>>
>>>
>>>"Jack Jackson" <jjackson@xxxxxx> wrote in message
>>>news:f67c84lj9a92i4ds6rk7vrbnpa0f517mn5@xxxxxx
>>>> You specify the connection in the command object.
>>>>
>>>> assCmd = New OleDb.OleDbCommand( _
>>>> "SELECT * from tblAssets where asset_tag=?", Con)
>>>> assAdapter = New OleDbAdapter(assCmd)
>>>>
>>>> or
>>>> assCmd = ...
>>>> Dim assAdapter as New OleDbAdapter
>>>> assAdapter.SelectCommand = assCmd
>>>>
>>>>
>>>> On Mon, 21 Jul 2008 23:05:29 -0600, "bill" <bill@xxxxxx>
>>>> wrote:
>>>>
>>>>>Sorry I see where you were going with that and you are right. It works
>>>>>like
>>>>>this:
>>>>>assAdapter = New OleDb.OleDbDataAdapter '(assCmd, Con)
>>>>>
>>>>>What I don't see in the properties now is how to add the command and
>>>>>the
>>>>>connection to the dataAdapter. Can you help me there since you've
>>>>>almost
>>>>>done it all now?
>>>>>
>>>>>Thank you!
>>>>>
>>>>>"bill"<bill@xxxxxx> wrote in message
>>>>>news:OhRK3f76IHA.5012@xxxxxx
>>>>>> It's still the assAdapter that errors out in this. It's not declared
>>>>>> anywhere else so I just don't see why this is happening. If i take
>>>>>> out
>>>>>> the first declaration there are even more errors that come up.
>>>>>>
>>>>>> "Jack Jackson" <jjackson@xxxxxx> wrote in message
>>>>>> news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
>>>>>>> This is exactly the same problem you had in the previous example.
>>>>>>>
>>>>>>> Either remove the first Dim (the best solution), or change the
>>>>>>> second
>>>>>>> one to just an assignment statement:
>>>>>>>
>>>>>>> assCmd = New OleDb.OleDbCommand( _
>>>>>>> "SELECT * from tblAssets where asset_tag=?")
>>>>>>>
>>>>>>> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
>>>>>>> wrote:
>>>>>>>
>>>>>>>>Does anyone see why I'm getting this message? It errors out on line
>>>>>>>>5
>>>>>>>>at
>>>>>>>>"assAdapter"?
>>>>>>>>Dim Con = New
>>>>>>>>OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;"
>>>>>>>>&
>>>>>>>>"data source=c:\_Archive\Documentation - Projects\Hardware
>>>>>>>>Tracking -
>>>>>>>>2008\IT_Assets.mdb")
>>>>>>>>
>>>>>>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>>>>>>
>>>>>>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>>>>>asset_tag=?")
>>>>>>>>
>>>>>>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>>>>>>cboAsset.Text
>>>>>>>>
>>>>>>>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>>>>>>>
>>>>>>>>Dim assDT As New DataTable
>>>>>>>>
>>>>>>>>'Release the instances of the above objects
>>>>>>>>
>>>>>>>>assAdapter.Fill(assDT)
>>>>>>>>
>>>>>>>>assAdapter.Dispose()
>>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>
>

My System SpecsSystem Spec
Old 07-22-2008   #2 (permalink)
Jack Jackson


 
 

Re: Local variable assAdapter already declared in block?

This is exactly the same problem you had in the previous example.

Either remove the first Dim (the best solution), or change the second
one to just an assignment statement:

assCmd = New OleDb.OleDbCommand( _
"SELECT * from tblAssets where asset_tag=?")

On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
wrote:
Quote:

>Does anyone see why I'm getting this message? It errors out on line 5 at
>"assAdapter"?
>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>2008\IT_Assets.mdb")
>
>Dim assAdapter As OleDb.OleDbDataAdapter
>
>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>asset_tag=?")
>
>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value = cboAsset.Text
>
>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>
>Dim assDT As New DataTable
>
>'Release the instances of the above objects
>
>assAdapter.Fill(assDT)
>
>assAdapter.Dispose()
>
My System SpecsSystem Spec
Old 07-22-2008   #3 (permalink)
bill


 
 

Re: Local variable assAdapter already declared in block?

It's still the assAdapter that errors out in this. It's not declared
anywhere else so I just don't see why this is happening. If i take out the
first declaration there are even more errors that come up.

"Jack Jackson" <jjackson@xxxxxx> wrote in message
news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
Quote:

> This is exactly the same problem you had in the previous example.
>
> Either remove the first Dim (the best solution), or change the second
> one to just an assignment statement:
>
> assCmd = New OleDb.OleDbCommand( _
> "SELECT * from tblAssets where asset_tag=?")
>
> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
> wrote:
>
Quote:

>>Does anyone see why I'm getting this message? It errors out on line 5 at
>>"assAdapter"?
>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>2008\IT_Assets.mdb")
>>
>>Dim assAdapter As OleDb.OleDbDataAdapter
>>
>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>asset_tag=?")
>>
>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>cboAsset.Text
>>
>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>
>>Dim assDT As New DataTable
>>
>>'Release the instances of the above objects
>>
>>assAdapter.Fill(assDT)
>>
>>assAdapter.Dispose()
>>

My System SpecsSystem Spec
Old 07-22-2008   #4 (permalink)
bill


 
 

Re: Local variable assAdapter already declared in block?

Sorry I see where you were going with that and you are right. It works like
this:
assAdapter = New OleDb.OleDbDataAdapter '(assCmd, Con)

What I don't see in the properties now is how to add the command and the
connection to the dataAdapter. Can you help me there since you've almost
done it all now?

Thank you!

"bill"<bill@xxxxxx> wrote in message
news:OhRK3f76IHA.5012@xxxxxx
Quote:

> It's still the assAdapter that errors out in this. It's not declared
> anywhere else so I just don't see why this is happening. If i take out
> the first declaration there are even more errors that come up.
>
> "Jack Jackson" <jjackson@xxxxxx> wrote in message
> news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
Quote:

>> This is exactly the same problem you had in the previous example.
>>
>> Either remove the first Dim (the best solution), or change the second
>> one to just an assignment statement:
>>
>> assCmd = New OleDb.OleDbCommand( _
>> "SELECT * from tblAssets where asset_tag=?")
>>
>> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
>> wrote:
>>
Quote:

>>>Does anyone see why I'm getting this message? It errors out on line 5 at
>>>"assAdapter"?
>>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
>>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>>2008\IT_Assets.mdb")
>>>
>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>
>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>asset_tag=?")
>>>
>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>cboAsset.Text
>>>
>>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>>
>>>Dim assDT As New DataTable
>>>
>>>'Release the instances of the above objects
>>>
>>>assAdapter.Fill(assDT)
>>>
>>>assAdapter.Dispose()
>>>
>
>

My System SpecsSystem Spec
Old 07-22-2008   #5 (permalink)
Jack Jackson


 
 

Re: Local variable assAdapter already declared in block?

You specify the connection in the command object.

assCmd = New OleDb.OleDbCommand( _
"SELECT * from tblAssets where asset_tag=?", Con)
assAdapter = New OleDbAdapter(assCmd)

or
assCmd = ...
Dim assAdapter as New OleDbAdapter
assAdapter.SelectCommand = assCmd


On Mon, 21 Jul 2008 23:05:29 -0600, "bill" <bill@xxxxxx>
wrote:
Quote:

>Sorry I see where you were going with that and you are right. It works like
>this:
>assAdapter = New OleDb.OleDbDataAdapter '(assCmd, Con)
>
>What I don't see in the properties now is how to add the command and the
>connection to the dataAdapter. Can you help me there since you've almost
>done it all now?
>
>Thank you!
>
>"bill"<bill@xxxxxx> wrote in message
>news:OhRK3f76IHA.5012@xxxxxx
Quote:

>> It's still the assAdapter that errors out in this. It's not declared
>> anywhere else so I just don't see why this is happening. If i take out
>> the first declaration there are even more errors that come up.
>>
>> "Jack Jackson" <jjackson@xxxxxx> wrote in message
>> news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
Quote:

>>> This is exactly the same problem you had in the previous example.
>>>
>>> Either remove the first Dim (the best solution), or change the second
>>> one to just an assignment statement:
>>>
>>> assCmd = New OleDb.OleDbCommand( _
>>> "SELECT * from tblAssets where asset_tag=?")
>>>
>>> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
>>> wrote:
>>>
>>>>Does anyone see why I'm getting this message? It errors out on line 5 at
>>>>"assAdapter"?
>>>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
>>>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>>>2008\IT_Assets.mdb")
>>>>
>>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>>
>>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>asset_tag=?")
>>>>
>>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>>cboAsset.Text
>>>>
>>>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>>>
>>>>Dim assDT As New DataTable
>>>>
>>>>'Release the instances of the above objects
>>>>
>>>>assAdapter.Fill(assDT)
>>>>
>>>>assAdapter.Dispose()
>>>>
>>
>>
>
My System SpecsSystem Spec
Old 07-22-2008   #6 (permalink)
bill


 
 

Re: Local variable assAdapter already declared in block?

Thank you again! That got it Though there is more now.... I get an error
at "assAdapter.fill(assDT)" that says "fill: SelectCommand.Connection
property has not been initialized? Do you see why?
Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
2008\IT_Assets.mdb")

Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
asset_tag=?")

Dim assAdapter As OleDb.OleDbDataAdapter

assAdapter = New OleDb.OleDbDataAdapter(assCmd)

'Dim assCmd As OleDb.OleDbCommand

assCmd = New OleDb.OleDbCommand("SELECT * from tblAssets where asset_tag=?",
Con)

assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value = cboAsset.Text

Dim assDT As New DataTable

'Need to initialize the dataAdapter here

'Release the instances of the above objects

assAdapter.Fill(assDT)

'assAdapter.Dispose()

Me.DataGridView1.DataSource = assDT

End If



"Jack Jackson" <jjackson@xxxxxx> wrote in message
news:f67c84lj9a92i4ds6rk7vrbnpa0f517mn5@xxxxxx
Quote:

> You specify the connection in the command object.
>
> assCmd = New OleDb.OleDbCommand( _
> "SELECT * from tblAssets where asset_tag=?", Con)
> assAdapter = New OleDbAdapter(assCmd)
>
> or
> assCmd = ...
> Dim assAdapter as New OleDbAdapter
> assAdapter.SelectCommand = assCmd
>
>
> On Mon, 21 Jul 2008 23:05:29 -0600, "bill" <bill@xxxxxx>
> wrote:
>
Quote:

>>Sorry I see where you were going with that and you are right. It works
>>like
>>this:
>>assAdapter = New OleDb.OleDbDataAdapter '(assCmd, Con)
>>
>>What I don't see in the properties now is how to add the command and the
>>connection to the dataAdapter. Can you help me there since you've almost
>>done it all now?
>>
>>Thank you!
>>
>>"bill"<bill@xxxxxx> wrote in message
>>news:OhRK3f76IHA.5012@xxxxxx
Quote:

>>> It's still the assAdapter that errors out in this. It's not declared
>>> anywhere else so I just don't see why this is happening. If i take out
>>> the first declaration there are even more errors that come up.
>>>
>>> "Jack Jackson" <jjackson@xxxxxx> wrote in message
>>> news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
>>>> This is exactly the same problem you had in the previous example.
>>>>
>>>> Either remove the first Dim (the best solution), or change the second
>>>> one to just an assignment statement:
>>>>
>>>> assCmd = New OleDb.OleDbCommand( _
>>>> "SELECT * from tblAssets where asset_tag=?")
>>>>
>>>> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
>>>> wrote:
>>>>
>>>>>Does anyone see why I'm getting this message? It errors out on line 5
>>>>>at
>>>>>"assAdapter"?
>>>>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;"
>>>>>&
>>>>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>>>>2008\IT_Assets.mdb")
>>>>>
>>>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>>>
>>>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>>asset_tag=?")
>>>>>
>>>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>>>cboAsset.Text
>>>>>
>>>>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>>>>
>>>>>Dim assDT As New DataTable
>>>>>
>>>>>'Release the instances of the above objects
>>>>>
>>>>>assAdapter.Fill(assDT)
>>>>>
>>>>>assAdapter.Dispose()
>>>>>
>>>
>>>
>>

My System SpecsSystem Spec
Old 07-23-2008   #7 (permalink)
Jack Jackson


 
 

Re: Local variable assAdapter already declared in block?

Sure. The message says it all. The DataAdapter's Select command,
which is built from the text you pass to the DataAdapter's
constructor, doesn't have any connection info.

See my comments below.
Quote:
Quote:

>> assCmd = New OleDb.OleDbCommand( _
>> "SELECT * from tblAssets where asset_tag=?", Con)
>> assAdapter = New OleDbAdapter(assCmd)
On Tue, 22 Jul 2008 18:05:09 -0600, "bill" <bill@xxxxxx>
wrote:
Quote:

>Thank you again! That got it Though there is more now.... I get an error
>at "assAdapter.fill(assDT)" that says "fill: SelectCommand.Connection
>property has not been initialized? Do you see why?
>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>2008\IT_Assets.mdb")
The following line creates an OleDbCommand without a connection
object.
Quote:

>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>asset_tag=?")
>
>Dim assAdapter As OleDb.OleDbDataAdapter
The following line creates a DataAdapter from the OleDbCommand object
that doesn't have a connection object.
Quote:

>assAdapter = New OleDb.OleDbDataAdapter(assCmd)
>
>'Dim assCmd As OleDb.OleDbCommand
The following line creates a second command object with the same
select as the previous one, this time with a connection object. This
command object is never used. You should get rid of this line, and
add Con as a second parameter to the previous OleDbCommand.
Quote:

>assCmd = New OleDb.OleDbCommand("SELECT * from tblAssets where asset_tag=?",
>Con)
>
>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value = cboAsset.Text
>
>Dim assDT As New DataTable
>
>'Need to initialize the dataAdapter here
>
>'Release the instances of the above objects
>
>assAdapter.Fill(assDT)
>
>'assAdapter.Dispose()
>
>Me.DataGridView1.DataSource = assDT
>
>End If
>
>
>
>"Jack Jackson" <jjackson@xxxxxx> wrote in message
>news:f67c84lj9a92i4ds6rk7vrbnpa0f517mn5@xxxxxx
Quote:

>> You specify the connection in the command object.
>>
>> assCmd = New OleDb.OleDbCommand( _
>> "SELECT * from tblAssets where asset_tag=?", Con)
>> assAdapter = New OleDbAdapter(assCmd)
>>
>> or
>> assCmd = ...
>> Dim assAdapter as New OleDbAdapter
>> assAdapter.SelectCommand = assCmd
>>
>>
>> On Mon, 21 Jul 2008 23:05:29 -0600, "bill" <bill@xxxxxx>
>> wrote:
>>
Quote:

>>>Sorry I see where you were going with that and you are right. It works
>>>like
>>>this:
>>>assAdapter = New OleDb.OleDbDataAdapter '(assCmd, Con)
>>>
>>>What I don't see in the properties now is how to add the command and the
>>>connection to the dataAdapter. Can you help me there since you've almost
>>>done it all now?
>>>
>>>Thank you!
>>>
>>>"bill"<bill@xxxxxx> wrote in message
>>>news:OhRK3f76IHA.5012@xxxxxx
>>>> It's still the assAdapter that errors out in this. It's not declared
>>>> anywhere else so I just don't see why this is happening. If i take out
>>>> the first declaration there are even more errors that come up.
>>>>
>>>> "Jack Jackson" <jjackson@xxxxxx> wrote in message
>>>> news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
>>>>> This is exactly the same problem you had in the previous example.
>>>>>
>>>>> Either remove the first Dim (the best solution), or change the second
>>>>> one to just an assignment statement:
>>>>>
>>>>> assCmd = New OleDb.OleDbCommand( _
>>>>> "SELECT * from tblAssets where asset_tag=?")
>>>>>
>>>>> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
>>>>> wrote:
>>>>>
>>>>>>Does anyone see why I'm getting this message? It errors out on line 5
>>>>>>at
>>>>>>"assAdapter"?
>>>>>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;"
>>>>>>&
>>>>>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>>>>>2008\IT_Assets.mdb")
>>>>>>
>>>>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>>>>
>>>>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>>>asset_tag=?")
>>>>>>
>>>>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>>>>cboAsset.Text
>>>>>>
>>>>>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>>>>>
>>>>>>Dim assDT As New DataTable
>>>>>>
>>>>>>'Release the instances of the above objects
>>>>>>
>>>>>>assAdapter.Fill(assDT)
>>>>>>
>>>>>>assAdapter.Dispose()
>>>>>>
>>>>
>>>>
>>>
>
My System SpecsSystem Spec
Old 07-23-2008   #8 (permalink)
bill


 
 

Re: Local variable assAdapter already declared in block?

Oh man, I should have seen that. I comment out that lin, add the con to the
second and it works perfectly. Thank you so much! You have been incredibly
helpful and patient and I really appreciate it. I have learned allot!
Thank you!
Bill Bray

"Jack Jackson" <jjackson@xxxxxx> wrote in message
newskid841jv1v9t9r705clrbc5bphn5u8kgr@xxxxxx
Quote:

> Sure. The message says it all. The DataAdapter's Select command,
> which is built from the text you pass to the DataAdapter's
> constructor, doesn't have any connection info.
>
> See my comments below.
>
Quote:
Quote:

>>> assCmd = New OleDb.OleDbCommand( _
>>> "SELECT * from tblAssets where asset_tag=?", Con)
>>> assAdapter = New OleDbAdapter(assCmd)
>
> On Tue, 22 Jul 2008 18:05:09 -0600, "bill" <bill@xxxxxx>
> wrote:
>
Quote:

>>Thank you again! That got it Though there is more now.... I get an
>>error
>>at "assAdapter.fill(assDT)" that says "fill: SelectCommand.Connection
>>property has not been initialized? Do you see why?
>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>2008\IT_Assets.mdb")
>
> The following line creates an OleDbCommand without a connection
> object.
>
Quote:

>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>asset_tag=?")
>>
>>Dim assAdapter As OleDb.OleDbDataAdapter
>
> The following line creates a DataAdapter from the OleDbCommand object
> that doesn't have a connection object.
>
Quote:

>>assAdapter = New OleDb.OleDbDataAdapter(assCmd)
>>
>>'Dim assCmd As OleDb.OleDbCommand
>
> The following line creates a second command object with the same
> select as the previous one, this time with a connection object. This
> command object is never used. You should get rid of this line, and
> add Con as a second parameter to the previous OleDbCommand.
>
Quote:

>>assCmd = New OleDb.OleDbCommand("SELECT * from tblAssets where
>>asset_tag=?",
>>Con)
>>
>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>cboAsset.Text
>>
>>Dim assDT As New DataTable
>>
>>'Need to initialize the dataAdapter here
>>
>>'Release the instances of the above objects
>>
>>assAdapter.Fill(assDT)
>>
>>'assAdapter.Dispose()
>>
>>Me.DataGridView1.DataSource = assDT
>>
>>End If
>>
>>
>>
>>"Jack Jackson" <jjackson@xxxxxx> wrote in message
>>news:f67c84lj9a92i4ds6rk7vrbnpa0f517mn5@xxxxxx
Quote:

>>> You specify the connection in the command object.
>>>
>>> assCmd = New OleDb.OleDbCommand( _
>>> "SELECT * from tblAssets where asset_tag=?", Con)
>>> assAdapter = New OleDbAdapter(assCmd)
>>>
>>> or
>>> assCmd = ...
>>> Dim assAdapter as New OleDbAdapter
>>> assAdapter.SelectCommand = assCmd
>>>
>>>
>>> On Mon, 21 Jul 2008 23:05:29 -0600, "bill" <bill@xxxxxx>
>>> wrote:
>>>
>>>>Sorry I see where you were going with that and you are right. It works
>>>>like
>>>>this:
>>>>assAdapter = New OleDb.OleDbDataAdapter '(assCmd, Con)
>>>>
>>>>What I don't see in the properties now is how to add the command and the
>>>>connection to the dataAdapter. Can you help me there since you've
>>>>almost
>>>>done it all now?
>>>>
>>>>Thank you!
>>>>
>>>>"bill"<bill@xxxxxx> wrote in message
>>>>news:OhRK3f76IHA.5012@xxxxxx
>>>>> It's still the assAdapter that errors out in this. It's not declared
>>>>> anywhere else so I just don't see why this is happening. If i take
>>>>> out
>>>>> the first declaration there are even more errors that come up.
>>>>>
>>>>> "Jack Jackson" <jjackson@xxxxxx> wrote in message
>>>>> news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
>>>>>> This is exactly the same problem you had in the previous example.
>>>>>>
>>>>>> Either remove the first Dim (the best solution), or change the second
>>>>>> one to just an assignment statement:
>>>>>>
>>>>>> assCmd = New OleDb.OleDbCommand( _
>>>>>> "SELECT * from tblAssets where asset_tag=?")
>>>>>>
>>>>>> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
>>>>>> wrote:
>>>>>>
>>>>>>>Does anyone see why I'm getting this message? It errors out on line
>>>>>>>5
>>>>>>>at
>>>>>>>"assAdapter"?
>>>>>>>Dim Con = New
>>>>>>>OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;"
>>>>>>>&
>>>>>>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>>>>>>2008\IT_Assets.mdb")
>>>>>>>
>>>>>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>>>>>
>>>>>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>>>>asset_tag=?")
>>>>>>>
>>>>>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>>>>>cboAsset.Text
>>>>>>>
>>>>>>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>>>>>>
>>>>>>>Dim assDT As New DataTable
>>>>>>>
>>>>>>>'Release the instances of the above objects
>>>>>>>
>>>>>>>assAdapter.Fill(assDT)
>>>>>>>
>>>>>>>assAdapter.Dispose()
>>>>>>>
>>>>>
>>>>>
>>>>
>>

My System SpecsSystem Spec
Old 07-24-2008   #9 (permalink)
sloan


 
 

Re: Local variable assAdapter already declared in block?


Now you can work on your naming conventions.

The @$$Adaptor sounds like something you use to get a colonoscopy and you
have an oversized or undersized butt. (ha ha).

...



"bill" <bill@xxxxxx> wrote in message
news:ubas75J7IHA.4108@xxxxxx
Quote:

> Oh man, I should have seen that. I comment out that lin, add the con to
> the second and it works perfectly. Thank you so much! You have been
> incredibly helpful and patient and I really appreciate it. I have learned
> allot!
> Thank you!
> Bill Bray
>
> "Jack Jackson" <jjackson@xxxxxx> wrote in message
> newskid841jv1v9t9r705clrbc5bphn5u8kgr@xxxxxx
Quote:

>> Sure. The message says it all. The DataAdapter's Select command,
>> which is built from the text you pass to the DataAdapter's
>> constructor, doesn't have any connection info.
>>
>> See my comments below.
>>
Quote:

>>>> assCmd = New OleDb.OleDbCommand( _
>>>> "SELECT * from tblAssets where asset_tag=?", Con)
>>>> assAdapter = New OleDbAdapter(assCmd)
>>
>> On Tue, 22 Jul 2008 18:05:09 -0600, "bill" <bill@xxxxxx>
>> wrote:
>>
Quote:

>>>Thank you again! That got it Though there is more now.... I get an
>>>error
>>>at "assAdapter.fill(assDT)" that says "fill: SelectCommand.Connection
>>>property has not been initialized? Do you see why?
>>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
>>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>>2008\IT_Assets.mdb")
>>
>> The following line creates an OleDbCommand without a connection
>> object.
>>
Quote:

>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>asset_tag=?")
>>>
>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>
>> The following line creates a DataAdapter from the OleDbCommand object
>> that doesn't have a connection object.
>>
Quote:

>>>assAdapter = New OleDb.OleDbDataAdapter(assCmd)
>>>
>>>'Dim assCmd As OleDb.OleDbCommand
>>
>> The following line creates a second command object with the same
>> select as the previous one, this time with a connection object. This
>> command object is never used. You should get rid of this line, and
>> add Con as a second parameter to the previous OleDbCommand.
>>
Quote:

>>>assCmd = New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>asset_tag=?",
>>>Con)
>>>
>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>cboAsset.Text
>>>
>>>Dim assDT As New DataTable
>>>
>>>'Need to initialize the dataAdapter here
>>>
>>>'Release the instances of the above objects
>>>
>>>assAdapter.Fill(assDT)
>>>
>>>'assAdapter.Dispose()
>>>
>>>Me.DataGridView1.DataSource = assDT
>>>
>>>End If
>>>
>>>
>>>
>>>"Jack Jackson" <jjackson@xxxxxx> wrote in message
>>>news:f67c84lj9a92i4ds6rk7vrbnpa0f517mn5@xxxxxx
>>>> You specify the connection in the command object.
>>>>
>>>> assCmd = New OleDb.OleDbCommand( _
>>>> "SELECT * from tblAssets where asset_tag=?", Con)
>>>> assAdapter = New OleDbAdapter(assCmd)
>>>>
>>>> or
>>>> assCmd = ...
>>>> Dim assAdapter as New OleDbAdapter
>>>> assAdapter.SelectCommand = assCmd
>>>>
>>>>
>>>> On Mon, 21 Jul 2008 23:05:29 -0600, "bill" <bill@xxxxxx>
>>>> wrote:
>>>>
>>>>>Sorry I see where you were going with that and you are right. It works
>>>>>like
>>>>>this:
>>>>>assAdapter = New OleDb.OleDbDataAdapter '(assCmd, Con)
>>>>>
>>>>>What I don't see in the properties now is how to add the command and
>>>>>the
>>>>>connection to the dataAdapter. Can you help me there since you've
>>>>>almost
>>>>>done it all now?
>>>>>
>>>>>Thank you!
>>>>>
>>>>>"bill"<bill@xxxxxx> wrote in message
>>>>>news:OhRK3f76IHA.5012@xxxxxx
>>>>>> It's still the assAdapter that errors out in this. It's not declared
>>>>>> anywhere else so I just don't see why this is happening. If i take
>>>>>> out
>>>>>> the first declaration there are even more errors that come up.
>>>>>>
>>>>>> "Jack Jackson" <jjackson@xxxxxx> wrote in message
>>>>>> news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
>>>>>>> This is exactly the same problem you had in the previous example.
>>>>>>>
>>>>>>> Either remove the first Dim (the best solution), or change the
>>>>>>> second
>>>>>>> one to just an assignment statement:
>>>>>>>
>>>>>>> assCmd = New OleDb.OleDbCommand( _
>>>>>>> "SELECT * from tblAssets where asset_tag=?")
>>>>>>>
>>>>>>> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
>>>>>>> wrote:
>>>>>>>
>>>>>>>>Does anyone see why I'm getting this message? It errors out on line
>>>>>>>>5
>>>>>>>>at
>>>>>>>>"assAdapter"?
>>>>>>>>Dim Con = New
>>>>>>>>OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;"
>>>>>>>>&
>>>>>>>>"data source=c:\_Archive\Documentation - Projects\Hardware
>>>>>>>>Tracking -
>>>>>>>>2008\IT_Assets.mdb")
>>>>>>>>
>>>>>>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>>>>>>
>>>>>>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>>>>>asset_tag=?")
>>>>>>>>
>>>>>>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>>>>>>cboAsset.Text
>>>>>>>>
>>>>>>>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>>>>>>>
>>>>>>>>Dim assDT As New DataTable
>>>>>>>>
>>>>>>>>'Release the instances of the above objects
>>>>>>>>
>>>>>>>>assAdapter.Fill(assDT)
>>>>>>>>
>>>>>>>>assAdapter.Dispose()
>>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>
>

My System SpecsSystem Spec
Old 07-25-2008   #10 (permalink)
bill


 
 

Re: Local variable assAdapter already declared in block?

LOL! I thought someone would have said something sooner

It just made sense to me...it was a data adapter for the assets....but it
still made me chuckle.

"sloan" <sloan@xxxxxx> wrote in message
news:OOntyqZ7IHA.2416@xxxxxx
Quote:

>
> Now you can work on your naming conventions.
>
> The @$$Adaptor sounds like something you use to get a colonoscopy and you
> have an oversized or undersized butt. (ha ha).
>
> ..
>
>
>
> "bill" <bill@xxxxxx> wrote in message
> news:ubas75J7IHA.4108@xxxxxx
Quote:

>> Oh man, I should have seen that. I comment out that lin, add the con to
>> the second and it works perfectly. Thank you so much! You have been
>> incredibly helpful and patient and I really appreciate it. I have
>> learned allot!
>> Thank you!
>> Bill Bray
>>
>> "Jack Jackson" <jjackson@xxxxxx> wrote in message
>> newskid841jv1v9t9r705clrbc5bphn5u8kgr@xxxxxx
Quote:

>>> Sure. The message says it all. The DataAdapter's Select command,
>>> which is built from the text you pass to the DataAdapter's
>>> constructor, doesn't have any connection info.
>>>
>>> See my comments below.
>>>
>>>>> assCmd = New OleDb.OleDbCommand( _
>>>>> "SELECT * from tblAssets where asset_tag=?", Con)
>>>>> assAdapter = New OleDbAdapter(assCmd)
>>>
>>> On Tue, 22 Jul 2008 18:05:09 -0600, "bill" <bill@xxxxxx>
>>> wrote:
>>>
>>>>Thank you again! That got it Though there is more now.... I get an
>>>>error
>>>>at "assAdapter.fill(assDT)" that says "fill: SelectCommand.Connection
>>>>property has not been initialized? Do you see why?
>>>>Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;"
>>>>&
>>>>"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
>>>>2008\IT_Assets.mdb")
>>>
>>> The following line creates an OleDbCommand without a connection
>>> object.
>>>
>>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>asset_tag=?")
>>>>
>>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>
>>> The following line creates a DataAdapter from the OleDbCommand object
>>> that doesn't have a connection object.
>>>
>>>>assAdapter = New OleDb.OleDbDataAdapter(assCmd)
>>>>
>>>>'Dim assCmd As OleDb.OleDbCommand
>>>
>>> The following line creates a second command object with the same
>>> select as the previous one, this time with a connection object. This
>>> command object is never used. You should get rid of this line, and
>>> add Con as a second parameter to the previous OleDbCommand.
>>>
>>>>assCmd = New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>asset_tag=?",
>>>>Con)
>>>>
>>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>>cboAsset.Text
>>>>
>>>>Dim assDT As New DataTable
>>>>
>>>>'Need to initialize the dataAdapter here
>>>>
>>>>'Release the instances of the above objects
>>>>
>>>>assAdapter.Fill(assDT)
>>>>
>>>>'assAdapter.Dispose()
>>>>
>>>>Me.DataGridView1.DataSource = assDT
>>>>
>>>>End If
>>>>
>>>>
>>>>
>>>>"Jack Jackson" <jjackson@xxxxxx> wrote in message
>>>>news:f67c84lj9a92i4ds6rk7vrbnpa0f517mn5@xxxxxx
>>>>> You specify the connection in the command object.
>>>>>
>>>>> assCmd = New OleDb.OleDbCommand( _
>>>>> "SELECT * from tblAssets where asset_tag=?", Con)
>>>>> assAdapter = New OleDbAdapter(assCmd)
>>>>>
>>>>> or
>>>>> assCmd = ...
>>>>> Dim assAdapter as New OleDbAdapter
>>>>> assAdapter.SelectCommand = assCmd
>>>>>
>>>>>
>>>>> On Mon, 21 Jul 2008 23:05:29 -0600, "bill" <bill@xxxxxx>
>>>>> wrote:
>>>>>
>>>>>>Sorry I see where you were going with that and you are right. It
>>>>>>works
>>>>>>like
>>>>>>this:
>>>>>>assAdapter = New OleDb.OleDbDataAdapter '(assCmd, Con)
>>>>>>
>>>>>>What I don't see in the properties now is how to add the command and
>>>>>>the
>>>>>>connection to the dataAdapter. Can you help me there since you've
>>>>>>almost
>>>>>>done it all now?
>>>>>>
>>>>>>Thank you!
>>>>>>
>>>>>>"bill"<bill@xxxxxx> wrote in message
>>>>>>news:OhRK3f76IHA.5012@xxxxxx
>>>>>>> It's still the assAdapter that errors out in this. It's not
>>>>>>> declared
>>>>>>> anywhere else so I just don't see why this is happening. If i take
>>>>>>> out
>>>>>>> the first declaration there are even more errors that come up.
>>>>>>>
>>>>>>> "Jack Jackson" <jjackson@xxxxxx> wrote in message
>>>>>>> news:b5pa849kcqoh9e6m74c43r8866noafne1a@xxxxxx
>>>>>>>> This is exactly the same problem you had in the previous example.
>>>>>>>>
>>>>>>>> Either remove the first Dim (the best solution), or change the
>>>>>>>> second
>>>>>>>> one to just an assignment statement:
>>>>>>>>
>>>>>>>> assCmd = New OleDb.OleDbCommand( _
>>>>>>>> "SELECT * from tblAssets where asset_tag=?")
>>>>>>>>
>>>>>>>> On Mon, 21 Jul 2008 22:24:14 -0600, "bill" <bill@xxxxxx>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>Does anyone see why I'm getting this message? It errors out on
>>>>>>>>>line 5
>>>>>>>>>at
>>>>>>>>>"assAdapter"?
>>>>>>>>>Dim Con = New
>>>>>>>>>OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;"
>>>>>>>>>&
>>>>>>>>>"data source=c:\_Archive\Documentation - Projects\Hardware
>>>>>>>>>Tracking -
>>>>>>>>>2008\IT_Assets.mdb")
>>>>>>>>>
>>>>>>>>>Dim assAdapter As OleDb.OleDbDataAdapter
>>>>>>>>>
>>>>>>>>>Dim assCmd As New OleDb.OleDbCommand("SELECT * from tblAssets where
>>>>>>>>>asset_tag=?")
>>>>>>>>>
>>>>>>>>>assCmd.Parameters.Add("asset_tag", OleDbType.VarChar).Value =
>>>>>>>>>cboAsset.Text
>>>>>>>>>
>>>>>>>>>Dim assAdapter As New OleDb.OleDbDataAdapter(assCmd, Con)
>>>>>>>>>
>>>>>>>>>Dim assDT As New DataTable
>>>>>>>>>
>>>>>>>>>'Release the instances of the above objects
>>>>>>>>>
>>>>>>>>>assAdapter.Fill(assDT)
>>>>>>>>>
>>>>>>>>>assAdapter.Dispose()
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>
>>
>>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Add local machine users to local admin group via GPO .NET General
Two Ethernet Cards, local shows as limited instead of as local Vista networking & sharing
How can I ensure that a variable is a built-in powershell variable? PowerShell
“Maddenoliday” Declared in Madden, Miss. (pop. 74), to Celebrate Launch of “Madden NFL 07” on Xbox 360 Vista News


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46