2 Replies - 4508 Views - Last Post: 13 August 2009 - 06:01 PM Rate Topic: -----

#1 xoops  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 06-August 09

Cannot display data in DataGridView using adodb vb.net

Posted 13 August 2009 - 03:50 AM

Private Sub frmDAFTARGAJI_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		Try
			If adcLEDGER.State = ADODB.ObjectStateEnum.adStateOpen Then adcLEDGER.Close()
			adcLEDGER.ConnectionString = strCONNECT
			adcLEDGER.Open()
		Catch ex As Exception
			MsgBox(ex.Message)
		End Try
   
		adrCURR.CursorLocation = ADODB.CursorLocationEnum.adUseClient
		adrCURR.Open("Select * from MS_UMR ORDER BY TAHUN", adcLEDGER, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockPessimistic)
		tdgShow.DataSource = adrCURR
		tdgShow.Refresh()

		adcLEDGER.Close()

	End Sub




Why i cannot display data in datagridview??? What wrong with my code. I'm using VS2008 in vb6 is working???

I want to not all field database display in datagridview??

This post has been edited by xoops: 13 August 2009 - 04:06 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Cannot display data in DataGridView using adodb vb.net

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2263
  • View blog
  • Posts: 9,468
  • Joined: 29-May 08

Re: Cannot display data in DataGridView using adodb vb.net

Posted 13 August 2009 - 04:32 AM

It'll a lot easier to use a TableAdapter.

Solution Explorer-> Add Existing Item -> Your Database. (I'm going to use NorthWind)
This will add too new Items to the Solution Explorer the database and a DataSet.

Double Click the Data Set.

Find The Table Named MS_UMR -> Left Click on it -> Add Query
Select the first option as your returning rows.
Enter the Query Select * from MS_UMR ORDER BY TAHUN

Deselect Add if it selected.
Give the Query a name like GetDataByTAHUN
The OK

This will generate the correct code for you (behind the scenes)
.
On the form a DataGridView, In the DataSource -> Other Sources -> pick correct table.
The like a the form code, there should be a line similar to one below.
 Me.TAHUNTableAdapter.Fill( {Your Table Name})



When you want to populate the DataViewGrid
Me.DataGridView1.DataSourece=Me.TAHUNTableAdapter.GetDataByTAHUN



Add is if be magic your data is the grid.
Was This Post Helpful? 0
  • +
  • -

#3 xoops  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 06-August 09

Re: Cannot display data in DataGridView using adodb vb.net

Posted 13 August 2009 - 06:01 PM

thank's...This code is work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1