Help Out of ideas for problem

i dont now what to do :s

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 2928 Views - Last Post: 10 January 2011 - 02:59 AM Rate Topic: -----

#1 cornetto456  Icon User is offline

  • D.I.C Regular

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

Help Out of ideas for problem

Posted 03 January 2011 - 08:13 AM

hello i tried to make a phone book but i having some problems inserting it to the databank and then updating the Datagrid view


i use a Dialog to input the contact details

i have 7 dialog's and 7 Label's

Name + Textbox for giving contact details , ...

then i click the button and i thougt to use this code
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'I have set it to false so they have to use the dialog to make the contacts but i dont think its the best way'
        Form2.DataGridView1.AllowUserToAddRows = True
'Simpel Check For checking phone number and Name has values(user must give the value)'
        If TextBox1.Text = "" And TextBox6.Text = "" Then
     'if not a msgbox shows up with the text your forgotten the name and phone number of the contact plz fill these in'
            
MsgBox("U bent vergeten de voornaam en telefoon nummer   in te vullen , Vul die Aub in !", MsgBoxStyle.Information, "Oei u bent precies iets vergeten")
'Title U have forgotten somthing'
        End If
 

now this what i tried
'then i got the error :Object reference not set to an instance of an object.'
        Form2.DataGridView1.CurrentRow.Cells(0).Value = TextBox1.Text



      'Then i get the error:	Value of type 'String' cannot be converted to System.Windows.Forms.DataGridViewTextBoxColumn.' 
 Form2.VoornaamDataGridViewTextBoxColumn = TextBox1.Text



But now i dont now what else i can do any sugestions ????

Thx


Arno(Cornetto456)

This post has been edited by cornetto456: 03 January 2011 - 08:14 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Help Out of ideas for problem

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Help Out of ideas for problem

Posted 03 January 2011 - 08:56 AM

what about this:
Form2.DataGridView1.Rows.Add(1)
Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(0).Value=TextBox1.Text



Where you get the rows that you have and add it at the last one

EDIT: oh i forget to mention that you must add a row before that check the corrected code

This post has been edited by NoBrain: 03 January 2011 - 08:58 AM

Was This Post Helpful? 1
  • +
  • -

#3 cornetto456  Icon User is offline

  • D.I.C Regular

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

Re: Help Out of ideas for problem

Posted 03 January 2011 - 08:58 AM

View PostNoBrain, on 03 January 2011 - 07:56 AM, said:

what about this:
Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(0).Value=TextBox1.Text



Where you get the rows that you have and add it at the last one

Thank you verry mutch it works thank you ^^
Was This Post Helpful? 0
  • +
  • -

#4 cornetto456  Icon User is offline

  • D.I.C Regular

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

Re: Help Out of ideas for problem

Posted 03 January 2011 - 09:22 AM

It work for putting it in but it wont save it to the database i use

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.DataGridView1.AllowUserToAddRows = True

        If TextBox1.Text = "" And TextBox6.Text = "" Then

            MsgBox("U bent vergeten de voornaam en telefoon nummer   in te vullen , Vul die Aub in !", MsgBoxStyle.Information, "Oei u bent precies iets vergeten")

        End If

        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(0).Value = TextBox1.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(1).Value = TextBox2.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(2).Value = TextBox3.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(3).Value = TextBox4.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(4).Value = TextBox5.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(5).Value = TextBox6.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(6).Value = TextBox7.Text
'This is what i use tho update the dataset but it dont update '
        Form2.ContactenTableAdapter.Update(Form2.Database1DataSet)
        Me.Close()

    End Sub







i thougt that was the way how you do it or is there a beter way ???
Was This Post Helpful? 0
  • +
  • -

#5 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Help Out of ideas for problem

Posted 03 January 2011 - 11:25 AM

well yea it only adds a row to a datagrid here is a link that you can see how to add it to the dataset
http://msdn.microsof...4(v=vs.80).aspx
Was This Post Helpful? 1
  • +
  • -

#6 cornetto456  Icon User is offline

  • D.I.C Regular

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

Re: Help Out of ideas for problem

Posted 03 January 2011 - 01:41 PM

View PostNoBrain, on 03 January 2011 - 10:25 AM, said:

well yea it only adds a row to a datagrid here is a link that you can see how to add it to the dataset
http://msdn.microsof...4(v=vs.80).aspx



then i get the error Reference to a non-shared member requires an object reference.

but i have also table's in the dataset (its called contact because im dutch) :S

so i use

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(0).Value = TextBox1.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(1).Value = TextBox2.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(2).Value = TextBox3.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(3).Value = TextBox4.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(4).Value = TextBox5.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(5).Value = TextBox6.Text

        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(6).Value = TextBox7.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(7).Value = TextBox8.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(8).Value = TextBox9.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(9).Value = TextBox10.Text
Form1.ContactenTableAdapter.Update(Database1.Dataset)


Srry for double post but im thinking i didn't tell evrything :P

i have a older version where i dont use a dialog

there i use
ContactenTableAdapter.Update(Database1.Dataset)

And that works

but when using the dialog it wont update i tried to use your solution i get also a error i did this
        Dim custom As DataRow = Database1DataSet.Tables("Contacten").NewRow()

        custom("Voornaam") = TextBox1.Text
        custom("Naam") = TextBox2.Text
        custom("Adres") = TextBox3.Text


        Database1DataSet.Tables("Contacten").Rows.Add(custom)



i will give a little bit more info of the table

table :
the name : Contacten
Rows:
-Voornaam
-Naam
-Adres
-...

I thougt that i must use the same fuction and thats
ContactenTableAdapter.Update(Database1Dataset)


i now nothing anymore


Thanks

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

#7 cornetto456  Icon User is offline

  • D.I.C Regular

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

Re: Help Out of ideas for problem

Posted 03 January 2011 - 02:07 PM

View Postcornetto456, on 03 January 2011 - 12:41 PM, said:

View PostNoBrain, on 03 January 2011 - 10:25 AM, said:

well yea it only adds a row to a datagrid here is a link that you can see how to add it to the dataset
http://msdn.microsof...4(v=vs.80).aspx



then i get the error Reference to a non-shared member requires an object reference.

but i have also table's in the dataset (its called contact because im dutch) :S

so i use

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(0).Value = TextBox1.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(1).Value = TextBox2.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(2).Value = TextBox3.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(3).Value = TextBox4.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(4).Value = TextBox5.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(5).Value = TextBox6.Text

        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(6).Value = TextBox7.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(7).Value = TextBox8.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(8).Value = TextBox9.Text
        Form1.DataGridView1.Rows(Form1.DataGridView1.Rows.Count - 1).Cells(9).Value = TextBox10.Text
Form1.ContactenTableAdapter.Update(Database1.Dataset)


Srry for double post but im thinking i didn't tell evrything :P

i have a older version where i dont use a dialog

there i use
ContactenTableAdapter.Update(Database1.Dataset)

And that works

but when using the dialog it wont update i tried to use your solution i get also a error i did this
        Dim custom As DataRow = Database1DataSet.Tables("Contacten").NewRow()

        custom("Voornaam") = TextBox1.Text
        custom("Naam") = TextBox2.Text
        custom("Adres") = TextBox3.Text


        Database1DataSet.Tables("Contacten").Rows.Add(custom)



i will give a little bit more info of the table

table :
the name : Contacten
Rows:
-Voornaam
-Naam
-Adres
-...

I thougt that i must use the same fuction and thats
ContactenTableAdapter.Update(Database1Dataset)


i now nothing anymore


Thanks

Arno(Cornetto456)

srry i didn't say what the error was

the error is : Reference to a non-shared member requires an object reference.
When i use
        Dim custom As DataRow
        custom = Database1DataSet.Tables("Contacten").NewRow()

        custom("Voornaam") = TextBox1.Text
        custom("Naam") = TextBox2.Text
        custom("Adres") = TextBox3.Text


        Database1DataSet.Tables("Contacten").Rows.Add(custom)

thanks

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

#8 cornetto456  Icon User is offline

  • D.I.C Regular

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

Re: Help Out of ideas for problem

Posted 04 January 2011 - 05:05 AM

But my datagridview is databound so i dont need to add rows or im ay ??
Was This Post Helpful? 0
  • +
  • -

#9 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Help Out of ideas for problem

Posted 04 January 2011 - 05:35 AM

so you use a dataset to populate your gridview? if so you should not be able to add the row in your grid as i show you. here is a test that i try and worked:
Imports System.Data.OleDb
Public Class Form1
    Private DA As 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()
        'Populate the grid'
        Dim DS As New DataSet
        DA = New OleDbDataAdapter("SELECT GName FROM GRPS WHERE 1", cnn)
        DA.Fill(DS, "GRPS")
        With DataGridView1
            .DataSource = DS.Tables("GRPS")
        End With
        cnn.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '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 DS As New DataSet
        DA = New OleDbDataAdapter("SELECT GName FROM GRPS WHERE 1", cnn)
        Dim CMD As New OleDbCommandBuilder(DA)
        DA.Fill(DS, "GRPS")
        'Insert new row in the database'
        Dim dsROW As DataRow
        dsROW = DS.Tables("GRPS").NewRow
        dsROW(0) = "NewRecord"
        DS.Tables("GRPS").Rows.Add(dsROW)
        DA.Update(DS, "GRPS")
        'Re populate the grid'
        DataGridView1.DataSource = DS.Tables("GRPS")
        'close the connection'
        cnn.Close()
    End Sub
End Class


This post has been edited by NoBrain: 04 January 2011 - 05:36 AM

Was This Post Helpful? 1
  • +
  • -

#10 cornetto456  Icon User is offline

  • D.I.C Regular

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

Re: Help Out of ideas for problem

Posted 04 January 2011 - 06:06 AM

View PostNoBrain, on 04 January 2011 - 04:35 AM, said:

so you use a dataset to populate your gridview? if so you should not be able to add the row in your grid as i show you. here is a test that i try and worked:
Imports System.Data.OleDb
Public Class Form1
    Private DA As 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()
        'Populate the grid'
        Dim DS As New DataSet
        DA = New OleDbDataAdapter("SELECT GName FROM GRPS WHERE 1", cnn)
        DA.Fill(DS, "GRPS")
        With DataGridView1
            .DataSource = DS.Tables("GRPS")
        End With
        cnn.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '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 DS As New DataSet
        DA = New OleDbDataAdapter("SELECT GName FROM GRPS WHERE 1", cnn)
        Dim CMD As New OleDbCommandBuilder(DA)
        DA.Fill(DS, "GRPS")
        'Insert new row in the database'
        Dim dsROW As DataRow
        dsROW = DS.Tables("GRPS").NewRow
        dsROW(0) = "NewRecord"
        DS.Tables("GRPS").Rows.Add(dsROW)
        DA.Update(DS, "GRPS")
        'Re populate the grid'
        DataGridView1.DataSource = DS.Tables("GRPS")
        'close the connection'
        cnn.Close()
    End Sub
End Class


Thx i tried it but i doesn't work because i work with the local database of Vb him self i think that its the correct code for connecting from a acces database

what i use is .sdf database but im stuck with the same problem :S

Any suggestions ???

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

#11 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Help Out of ideas for problem

Posted 04 January 2011 - 06:15 AM

what do you mean how do you populate your grid can you show me the code?
Was This Post Helpful? 1
  • +
  • -

#12 cornetto456  Icon User is offline

  • D.I.C Regular

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

Re: Help Out of ideas for problem

Posted 04 January 2011 - 07:08 AM


View PostNoBrain, on 04 January 2011 - 05:15 AM, said:

what do you mean how do you populate your grid can you show me the code?

How i populate the grid its a empty database where you can put new records in i use a Database thats has a connection with my datagrid and when i press the button the database will be updated with the records and then my datagrid view refreshs that what i want
or the other way can also like that there comes records in to the datagrid view and then i use a update to update it to the database for the update i think i need to use the
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(0).Value = TextBox1.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(1).Value = TextBox2.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(2).Value = TextBox3.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(3).Value = TextBox4.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(4).Value = TextBox5.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(5).Value = TextBox6.Text
        Form2.DataGridView1.Rows(Form2.DataGridView1.Rows.Count - 1).Cells(6).Value = TextBox7.Text
        Form2.ContactenTableAdapter.Update(Form2.Database1DataSet)

        Me.Close()



and for updating i use
Form2.ContactenTableAdapter.Update(Form2.Database1DataSet)


in my older version it worked but now it doesn't so thats how i populate it
and for populating it i use
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Database1DataSet.Contacten' table. You can move, or remove it, as needed.
        Me.ContactenTableAdapter.Fill(Me.Database1DataSet.Contacten)

    End Sub



thats how i fill it

Thanks

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

#13 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Help Out of ideas for problem

Posted 04 January 2011 - 07:21 AM

Ok so now you have DataAdapter(ContactenTableAdapter) and DataSet(Database1DataSet) right?
so what is the problem after you see my code to replace the Oledb things i use for the example with your data set and adapter:
Me.Database1DataSet.Contacten.Rows.Add(dsROW)
Me.ContactenTableAdapter.Update(Me.Database1DataSet)



the only thing you have to do is to add a new row as you can see how i do it in my code and to only change the dataset and dataadapter that i use with yours. The fact that i use Oledb is because i find some Access DB at my PC to test the code

This post has been edited by NoBrain: 04 January 2011 - 07:23 AM

Was This Post Helpful? 1
  • +
  • -

#14 cornetto456  Icon User is offline

  • D.I.C Regular

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

Re: Help Out of ideas for problem

Posted 04 January 2011 - 08:44 AM

View PostNoBrain, on 04 January 2011 - 06:21 AM, said:

Ok so now you have DataAdapter(ContactenTableAdapter) and DataSet(Database1DataSet) right?
so what is the problem after you see my code to replace the Oledb things i use for the example with your data set and adapter:
Me.Database1DataSet.Contacten.Rows.Add(dsROW)
Me.ContactenTableAdapter.Update(Me.Database1DataSet)



the only thing you have to do is to add a new row as you can see how i do it in my code and to only change the dataset and dataadapter that i use with yours. The fact that i use Oledb is because i find some Access DB at my PC to test the code

srry for the question again but i did this

  Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Database1DataSet.Contacten' table. You can move, or remove it, as needed.
        Me.ContactenTableAdapter.Fill(Me.Database1DataSet.Contacten)
        Dim DS As New DataSet
        'Insert new row in the database'
        Dim dsROW As DataRow
        'Re populate the grid'
        Me.Database1DataSet.Contacten.Rows.Add(dsROW)
        Me.ContactenTableAdapter.Update(Me.Database1DataSet)


And then i get a error on debug = "'row' argument cannot be null.
Parameter name: row" srry idk what to do (im just a beginner )


Any Sugestions solutions ???


thx

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

#15 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Help Out of ideas for problem

Posted 04 January 2011 - 08:58 AM

i dont think you follow my code correct. in my form load event i populate the grid with the existing items in my database:
    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()
        'Populate the grid'
        Dim DS As New DataSet
        DA = New OleDbDataAdapter("SELECT GName FROM GRPS WHERE 1", cnn)
        DA.Fill(DS, "GRPS")
        With DataGridView1
            .DataSource = DS.Tables("GRPS")
        End With
        cnn.Close()
    End Sub



as you will do with your Database. It only show the data from table GRPS in my database to the datagridview. while in the button1 click event i populate the new row and refresh the datagridveiw information:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '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 DS As New DataSet
        DA = New OleDbDataAdapter("SELECT GName FROM GRPS WHERE 1", cnn)
       'Command builder for the data adapter so you can insert rows'
        Dim CMD As New OleDbCommandBuilder(DA)
        DA.Fill(DS, "GRPS")
        'Insert new row in the database'
       'Create variable for the new row'
        Dim dsROW As DataRow
       'Init the new row using datasets table'
        dsROW = DS.Tables("GRPS").NewRow
       'Populate info in the rows fields(in this case there is only on field (GName))'
        dsROW(0) = "NewRecord"
       'Add the new row to the Datasets table'
        DS.Tables("GRPS").Rows.Add(dsROW)
       'Update the dataset'
        DA.Update(DS, "GRPS")
        'Re populate the grid'
        DataGridView1.DataSource = DS.Tables("GRPS")
        'close the connection'
        cnn.Close()
    End Sub



see if you want to add a new row in the table and in the database you will use my code from the button click. all you have to do is to use the reference that you use till now (Me.Database1DataSet.Contacten for dataset and Me.ContactenTableAdapter for dataadaptor). Also the code that you write and the error that you get is because you dont initialize the row and you dont fill any information see the above code.

This post has been edited by NoBrain: 04 January 2011 - 09:00 AM

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2