10 Replies - 2561 Views - Last Post: 11 March 2011 - 07:07 AM Rate Topic: -----

#1 chocolateprincess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 20-February 11

publishing data in datagrid view

Posted 10 March 2011 - 05:26 AM

there is another problem in my system.... after publishing my project, i find that my data in datagrid view is not updated as in the ms access database i wonder why.... here i gave my coding
Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.REKOD_PELAJARTableAdapter.Fill(Me.LcrsdDataSet4.REKOD_PELAJAR)
        Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Along\LCRS\LCRS\Lcrsd.mdb"
        Dim myConnection As OleDbConnection = New OleDbConnection
        myConnection.ConnectionString = connString
        Me.REKOD_PELAJARTableAdapter.Fill(Me.LcrsdDataSet4.REKOD_PELAJAR)
    End Sub




Is This A Good Question/Topic? 0
  • +

Replies To: publishing data in datagrid view

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,004
  • Joined: 12-June 08

Re: publishing data in datagrid view

Posted 10 March 2011 - 08:56 AM

Are you asking why your grid doesn't fill from the database, or why your database isn't relecting changes from the grid?
Was This Post Helpful? 0
  • +
  • -

#3 chocolateprincess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 20-February 11

Re: publishing data in datagrid view

Posted 10 March 2011 - 09:50 AM

why my grid doesn't fill from my ms access database
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,004
  • Joined: 12-June 08

Re: publishing data in datagrid view

Posted 10 March 2011 - 10:01 AM

A few questions:

Why is the fill method called at the beginning and end?
You have a connection string - where is it opened?
Does your adapter get the connection string at any point?
What does your select statement look like?
Is your dataset bound as the datasource for your grid?
Is the a table in the dataset specified as the datamember for the dataset?

This post has been edited by modi123_1: 10 March 2011 - 10:01 AM

Was This Post Helpful? 0
  • +
  • -

#5 chocolateprincess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 20-February 11

Re: publishing data in datagrid view

Posted 10 March 2011 - 10:14 AM

1) i did not notice that,
2,3)i don't know that,because the grid can display updated data before i publish my project,
4)i have no select statement in this form,
5, 6) yes
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,004
  • Joined: 12-June 08

Re: publishing data in datagrid view

Posted 10 March 2011 - 10:42 AM

Re: #4 - How do you expect the computer to know you want data back? You need *some* sort of select statement; either written by you or generated through a wizard.

Quote

2,3)i don't know that,because the grid can display updated data before i publish my project,

I have no idea what this means. Rephrase that.

Look at this tutorial: Populating a DataSet from a DataAdapter (ADO.NET)
http://msdn.microsof...y/bh8kx08z.aspx


It comes down to:
connection object
opening the connection
making a data adapter with the connection string and select statement
filling a dataset from the adapter
profit using the dataset!
Was This Post Helpful? 0
  • +
  • -

#7 chocolateprincess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 20-February 11

Re: publishing data in datagrid view

Posted 10 March 2011 - 10:59 AM

before publishing my project, i run it in vb.net and my datagridview can show new data that is inserted into the ms access database, but after i published my project, the datagridview did not show any new data that is inserted into the database
Was This Post Helpful? 0
  • +
  • -

#8 cornetto456   User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 439
  • Joined: 03-January 11

Re: publishing data in datagrid view

Posted 10 March 2011 - 01:32 PM

View Postchocolateprincess, on 10 March 2011 - 10:59 AM, said:

before publishing my project, i run it in vb.net and my datagridview can show new data that is inserted into the ms access database, but after i published my project, the datagridview did not show any new data that is inserted into the database

you need a SELECT statement for selecting the data say the table is called test and the colums are user pass then you say
SELECT [user] , [pass] FROM test

an indept tutorial on w3school (Over Here ;))

you have a connection string so thats alright :D

The select statement do you have to make (given above as an example)

and then the only thing you need to do is :
    Private DA As New OleDbDataAdapter
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Connection to the DB'
        Dim strCnn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\testnew.mdb" & _
                        "; Jet OLEDB:Database Password=blabla;"
        Dim cnn As New OleDbConnection(strCnn)
        cnn.Open()
        Dim CMbuild As New OleDbCommand

        CMbuild.Connection = cnn

        CMbuild.CommandText = "SELECT * FROM TEST"

        CMbuild.ExecuteNonQuery()

        DA.SelectCommand = CMbuild


This post has been edited by cornetto456: 11 March 2011 - 07:08 AM

Was This Post Helpful? 0
  • +
  • -

#9 chocolateprincess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 20-February 11

Re: publishing data in datagrid view

Posted 10 March 2011 - 04:15 PM

have error on
 DA.SelectCommand = CMbuild


saying that "Object reference not set to an instance of an object."
and it did not work.... :(
Was This Post Helpful? 0
  • +
  • -

#10 Kaustix   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 03-November 09

Re: publishing data in datagrid view

Posted 10 March 2011 - 06:04 PM

Your First Line
Private DA As OleDbDataAdapter



should be
Private DA As New OleDbDataAdapter



also make sure you close your connection when your done
something like :
cnn.Close()


This post has been edited by Kaustix: 10 March 2011 - 06:09 PM

Was This Post Helpful? 1
  • +
  • -

#11 cornetto456   User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 439
  • Joined: 03-January 11

Re: publishing data in datagrid view

Posted 11 March 2011 - 07:07 AM

View PostKaustix, on 10 March 2011 - 06:04 PM, said:

Your First Line
Private DA As OleDbDataAdapter



should be
Private DA As New OleDbDataAdapter



also make sure you close your connection when your done
something like :
cnn.Close()



Yea sorry always forget that :S

Arno(Cornetto456)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1