Solved

Access table size in VB.net

Posted on 2004-08-18
1
311 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
1 Comment
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 125 total points
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now