3 Replies - 486 Views - Last Post: 05 February 2013 - 10:16 PM Rate Topic: -----

#1 alobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 21-January 13

issues with datagridview, table and select statement: vb.net and accex

Posted 05 February 2013 - 10:23 AM

Hi,
I have been trying for the past one week to connect and load a datagridview ‘DatagridviewEmployeeID’ from a database HumanResourcesDB and ‘EmployTbl to no avail, could someone please help me. Bellow is my code. Right now it looks like I binding but I think binding what I need. Please help me

  Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click
        Dim cmd As OleDbCommand = New OleDbCommand()
        Dim connection As String = "Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Amaechi\Documents\Databases\Humanresouces.accdb"
        'Dim conn As OleDbConnection
        Dim ds As New DataSet
        'Dim connection As New OleDbConnection(connectionString)
        Dim dataAdapter As New OleDbDataAdapter(connectionString, connection)
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "getEmployID"
        connection.Open()
        dataAdapter.Fill(ds, "EmployeTbl")
        cmd.ExecuteNonQuery()
        connection.Close("")
        DataGridViewCheckEmployee.DataMember = "EmployeeTbl"



Is This A Good Question/Topic? 0
  • +

Replies To: issues with datagridview, table and select statement: vb.net and accex

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3369
  • View blog
  • Posts: 11,410
  • Joined: 12-December 12

Re: issues with datagridview, table and select statement: vb.net and accex

Posted 05 February 2013 - 11:24 AM

What error messages do you receive and what line numbers do they refer to?

But anyway:
You need to Open() a connection before you can use it.

You have spelt EmployTbl in three different ways; even the name of the database is different in your code than it is in your description.

This post has been edited by andrewsw: 05 February 2013 - 11:25 AM

Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3369
  • View blog
  • Posts: 11,410
  • Joined: 12-December 12

Re: issues with datagridview, table and select statement: vb.net and accex

Posted 05 February 2013 - 11:35 AM

..and your connection string is called connection (not a great name!) but you refer to it as connectionString.

ExecuteNonQuery() returns no rows..

I think you need to sit down and read through the documentation, or a tutorial, so that you understand what you are trying to do. You seem to be guessing - which is why you've gotten nowhere in (you say..) a week.

BTW When I paste your code into Visual Studio it lights up with wiggly lines! VS itself offers lots of hints on these errors.

This post has been edited by andrewsw: 05 February 2013 - 11:39 AM

Was This Post Helpful? 0
  • +
  • -

#4 alobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 21-January 13

Re: issues with datagridview, table and select statement: vb.net and accex

Posted 05 February 2013 - 10:16 PM

View Postandrewsw, on 05 February 2013 - 11:24 AM, said:

What error messages do you receive and what line numbers do they refer to?

But anyway:
You need to Open() a connection before you can use it.

You have spelt EmployTbl in three different ways; even the name of the database is different in your code than it is in your description.


andrew you are correct and I have started working on those issues(reading up on my connection/command Objects)
Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1