Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Go Back  Xtreme Visual Basic Talk > > > Error BC30451: Name 'adUseClient' is not declared


Reply
 
Thread Tools Display Modes
  #1  
Old 09-09-2009, 05:44 AM
Piglet's Avatar
Piglet Piglet is offline
Freshman
 
Join Date: Dec 2005
Location: London
Posts: 49
Question Error BC30451: Name 'adUseClient' is not declared


Hi everyone. I havent used VB for about 4 years so I am trying to refresh my memory for a project I am doing. I want to link it to an Access database and have the following code:

[
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click

Dim sqlstring As String

Dim conconnection As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
Dim rstrecordset As New ADODB.Recordset

conconnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\" & "database1.accdb;Mode=Read|Write"


conconnection.CursorLocation = adUseClient

conconnection.Open()


With cmdCommand
.ActiveConnection = conconnection
.CommandText = "SELECT * FROM tblRegister;"
.CommandType = adCmdText
End With

With rstrecordset
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open(cmdCommand)
End With
]

However when I run the program I get the following error messages:

error BC30451: Name 'App' is not declared.
error BC30451: Name 'adUseClient' is not declared.
error BC30451: Name 'adCmdText' is not declared.
error BC30451: Name 'adOpenStatic' is not declared.
error BC30451: Name 'adUseClient' is not declared.
error BC30451: Name 'adLockOptimistic' is not declared.

Is there some sort of Add-In or reference I need to add? I can't remember how I did it last time!

Thank you
Amy
Reply With Quote
  #2  
Old 09-09-2009, 07:47 AM
IUnknown's Avatar
IUnknown IUnknown is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Oct 2004
Location: Montréal
Posts: 1,135
Default

You're using ADO/ADODB but the code seems like .Net. You could continue using ADO (http://support.microsoft.com/kb/318559) but as you're coding a .Net app, you should consider moving over to ADO.Net.

Here is a link to ADO.Net data walkthroughs to get you started : http://msdn.microsoft.com/en-us/libr...8VS.80%29.aspx

This article should be of interest if moving from ADO to ADO.Net: http://msdn.microsoft.com/en-us/magazine/cc163954.aspx

HTH,
<iunknown />
__________________
win7 : vs 2008 : .Net 3.5
Reply With Quote
  #3  
Old 09-09-2009, 09:38 AM
Piglet's Avatar
Piglet Piglet is offline
Freshman
 
Join Date: Dec 2005
Location: London
Posts: 49
Default

Thanks for the reply. I think I would like to continue using ADO as this it what I used in my previous project and I dont have much time to complete the one I am doing now so dont want to start learning ADO.NET. I have added the ADODB reference to my project as its says to do in the link you sent but I still get the same errors. Any ideas?

Thank you
Amy
Reply With Quote
  #4  
Old 09-09-2009, 09:52 AM
IUnknown's Avatar
IUnknown IUnknown is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Oct 2004
Location: Montréal
Posts: 1,135
Default

You should be able to reference the enums like so:
Code:
...
    conconnection.CursorLocation = ADODB.CursorLocationEnum.adUseClient
    ...

    ...

    .CommandType = ADODB.CommandTypeEnum.adCmdText
    ...
You may want to add an Imports ADODB statement at the top of your form/class.

HTH,
<iunknown />
__________________
win7 : vs 2008 : .Net 3.5
Reply With Quote
  #5  
Old 09-11-2009, 02:58 AM
Piglet's Avatar
Piglet Piglet is offline
Freshman
 
Join Date: Dec 2005
Location: London
Posts: 49
Default

Thank you! seems to be working now with the following code:

Dim con As New ADODB.Connection()
Dim rs As New ADODB.Recordset()


con.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\osmana1\My Documents\Visual Studio 2008\Projects\Amy\Amy\calculations.mdb;Mode=Read|Write")
rs.Open("SELECT * FROM tblEasy", con, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText)
MessageBox.Show(rs(0).Value, "Testing")
_____
However it only works when i put a database of type .mdb in and it doesnt recognise .accdb file. Do I need to add something for it to be recognised? Thanks
Reply With Quote
  #6  
Old 09-11-2009, 06:50 AM
IUnknown's Avatar
IUnknown IUnknown is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Oct 2004
Location: Montréal
Posts: 1,135
Default

The connection needs to use the new OleDb provider for Access 2007, e.g.,
Code:
    .ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
          Application.StartupPath & "\" & "calculations.accdb;Persist Security Info=False;"
You can look up connection strings at http://www.connectionstrings.com

HTH,
<iunknown />
__________________
win7 : vs 2008 : .Net 3.5
Reply With Quote
  #7  
Old 09-13-2009, 01:26 PM
Piglet's Avatar
Piglet Piglet is offline
Freshman
 
Join Date: Dec 2005
Location: London
Posts: 49
Default

Thank you! I'll give it a go
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
 
Error BC30451: Name 'adUseClient' is not declared
Error BC30451: Name 'adUseClient' is not declared
 
-->