Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


VS 2008 dataset bound datagridview not showing the data inserted by other form


VS 2008 dataset bound datagridview not showing the data inserted by...

Author
Message
jazzyb
jazzyb
Forum God
Forum God (401 reputation)Forum God (401 reputation)Forum God (401 reputation)Forum God (401 reputation)Forum God (401 reputation)Forum God (401 reputation)Forum God (401 reputation)Forum God (401 reputation)Forum God (401 reputation)

Group: Forum Members
Posts: 1, Visits: 3
I am creating one application using visual basic.net and sqlce
I have two forms name Form1 and Form2.

I used Form1 to add data to database using OLeDb command
I used Form2 to show data in datagridview by using dataset

I used following code:

FFORM1 CODE is as following


Private Sub Add_data()

Try

Dim DBConn As OleDbConnection
Dim DBInsert As New OleDbCommand


DBConn = New OleDbConnection(Myconnection_String)
DBInsert.Connection = DBConn
DBInsert.Connection.Open()

DBInsert.CommandText = "INSERT INTO user(name, designation, age) VALUES (" + textbox1.text + "," + textbox2.text+ "," + textbox3.text + ")"

DBInsert.ExecuteNonQuery()

MsgBox("Data added successfully.", MsgBoxStyle.OkOnly)

DBConn.Close()
DBConn.Dispose()
Catch ex As System.Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub

This code insert the data succussfully


FORM 2 : In visual studio 2008 designer I added a dataset named 'mydataset' and tableadapter 'usertableadapter' and succesfully created Fill query. I added one datagridview to form2 and in design mode bind it to the mydataset and its binding source


ON FORM2 I CODE IS AS FOLLOWING.

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


Me.userTableAdapter.Fill(Me.myDataSet.user)
Me.DataGridView1.Refresh()
End Sub


My Problem is :

Form2 Datagridview show the old data only, it do not show the recently added data by form1. I mean when I build my application datagridview show the data which is already in the database, but it does not show the data which is added by the form1 during run time.
 
I have tried mydataset.acceptchanges(), mydataset.getchanges() but all these not worked for me

Some one suggested me to fill the datagridview at run time by using OLeDB command. Then I created Form3 to fill the datagridview2 by using OLedb command and datareader and found that Form3 shows the recently(added by Form1 at run time) added data.

Use of Designer dataset is required for me , because I am using the similar dataset to create report.


How my Form2 dataset,datagridview can show the latest modified data from the database.

Thanks


Begginner
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search