Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a new record in VB 2005

Status
Not open for further replies.

jpinto

Technical User
Dec 12, 2003
75
PT
I'm new to VB 2005. I've programmed for a while in VB 6 mas now that I started with VB 2005 I've been a little lost!

I've the following code to add a new record to an MS Access database:

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim newScrapRow As DataRow = ReportItDataSet.Tables("Scrap").NewRow()
        ReportItDataSet.Tables("Scrap").Rows.Add()
        newScrapRow("Tipo_Peça") = ScrapCombo
        newScrapRow("Qtd") = Qtdfield
        ReportItDataSet.Tables("Scrap").Rows.Add(newScrapRow)
        ScrapTableAdapter.Update(ReportItDataSet, "Scrap")
    End Sub

This is not working because I think I've some mistake in the last line:

Code:
 ScrapTableAdapter.Update(ReportItDataSet, "Scrap")

Can annybody help me please?

Thanks,

João Pinto
 
I still can't get it to work! Anny help please?

Thanks,

João Pinto
 
What exactly is the problem? Is it just not putting any data in the database? Is the information saved, but corrupted somehow? Are you getting any error messages? We need more information to be able to help you.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Yes, I'm not getting the information onto the database. I've tryed many ways but is not wrinting on the database.

João Pinto
 
Do you have the DataAdapter's InsertCommand defined? If so, can you let us see the code, or tell us how you set it up?

As I said, we need more information to help you.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
OK...I think I'm lost here! Let's start from the beginning please.

I've a form on my project;
I've a "ReportITDataSet" on it;
On "ReportItDataSet" I've a Table named "Scrap" with fields "Tipo_Peça" and "Qtd";
When I click a button on my form I want to insert a new record on table "Scrap";

What is the code for it, please?

I hope that the information now is enought!

Thanks in advance,

João Pinto
 
I've tryed for so many diferent ways but nothing looks to be working! In VB6 I use to do it with Data Recordsets and it was easy. In VB 2005, I still can't find the way to do it!

Can please someone help me?

Thanks,

João Pinto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top