Solved

Access table size in VB.net

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Object Oriented Programming, C#, referencing, scoping. 13 85
youtube blocking politics 4 79
Getting Variable not defined error in Python 1 41
Java array 10 57
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this post we will learn different types of Android Layout and some basics of an Android App.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

756 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