Solved

Access table size in VB.net

Posted on 2004-08-18
1
317 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 125 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

752 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