Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access table size in VB.net

Posted on 2004-08-18
1
Medium Priority
?
319 Views
Last Modified: 2012-06-27
Hi

I am trying to find out the size of a Microsoft Access Table in VB. I am using the following code.


        Dim cnn2 As OleDbConnection = New OleDbConnection()
        Dim cmd As OleDbCommand = New OleDbCommand()
        cnn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\server\file\News.mdb"
        cmd.CommandText = "select count(*) as c1 from Headline"

        cmd.CommandType = CommandType.Text
        cnn2.Open()
        newrow = cmd.ExecuteNonQuery()


and getting the following error

System.InvalidOperationException: ExecuteNonQuery: Connection property has not been initialized.

Is there another way of doing this or am I on the right lines
0
Comment
Question by:Cained
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 500 total points
ID: 11829386
you have not associated the Connectin object with the Command Object.  Try it this way:

        Dim cnn2 As OleDbConnection = New OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\server\file\News.mdb")
        Dim cmd As New OleDbCommand(cnn2)

        cmd.CommandText = "select count(*) as c1 from Headline"
        cmd.CommandType = CommandType.Text
        cnn2.Open()
        newrow = cmd.ExecuteNonQuery()

AW
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Progress

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question