|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem adding new row in Access Tablewant to save new record with this method i.e., non-SQL. It is not commiting changes. The "Update" statement has errors. 'Initialize Data Adapter and Data Table Objects TempDA.Fill(TempDS, "Temp") TempDT = TempDS.Tables("Temp") 'Temp is the name of table 'Store to Temporary Table 'Start Connection If Cn.State = ConnectionState.Closed Then Call StartConnection() End If TempNewRow = TempDT.NewRow() TempNewRow("Pno") = NewPNo TempNewRow("PLName") = tab1_namepl 'Add the new row TempDT.Rows.Add(TempNewRow) 'Commit Changes TempDS.AcceptChanges() dsChanges = TempDS.GetChanges TempDA.Update(dsChanges, "Temp") 'Increment Permit Number NewPNo = NewPNo + 1 Cn.Close() If TempDS.HasChanges(DataRowState.Added) Then MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly, "Success") End If Please also let me know which method for "Saving" record is fast (non-SQL). Hi,
When you call TempDS.AcceptChanges it marks all the records as unchanged. So dsChanges will not get any records. Ken --------------------- Show quoteHide quote "RPK" <R**@discussions.microsoft.com> wrote in message news:4DB26F5B-4ECB-4D45-8307-3C5D02454BDC@microsoft.com... >I am using following code to Add New Record in a Table (Temp in this case). >I > want to save new record with this method i.e., non-SQL. It is not > commiting > changes. The "Update" statement has errors. > > > 'Initialize Data Adapter and Data Table Objects > TempDA.Fill(TempDS, "Temp") > TempDT = TempDS.Tables("Temp") 'Temp is the name of table > > > 'Store to Temporary Table > 'Start Connection > If Cn.State = ConnectionState.Closed Then > Call StartConnection() > End If > > TempNewRow = TempDT.NewRow() > TempNewRow("Pno") = NewPNo > TempNewRow("PLName") = tab1_namepl > > 'Add the new row > TempDT.Rows.Add(TempNewRow) > > 'Commit Changes > TempDS.AcceptChanges() > > dsChanges = TempDS.GetChanges > TempDA.Update(dsChanges, "Temp") > > 'Increment Permit Number > NewPNo = NewPNo + 1 > Cn.Close() > > If TempDS.HasChanges(DataRowState.Added) Then > MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly, > "Success") > End If > > > Please also let me know which method for "Saving" record is fast > (non-SQL). Ken,
Please illustrate the lines where the changes are needed. Thanks. ---------------------------------------------------------------- Show quoteHide quote "Ken Tucker [MVP]" wrote: > Hi, > > When you call TempDS.AcceptChanges it marks all the records as > unchanged. So dsChanges will not get any records. > > Ken > --------------------- > "RPK" <R**@discussions.microsoft.com> wrote in message > news:4DB26F5B-4ECB-4D45-8307-3C5D02454BDC@microsoft.com... > >I am using following code to Add New Record in a Table (Temp in this case). > >I > > want to save new record with this method i.e., non-SQL. It is not > > commiting > > changes. The "Update" statement has errors. > > > > > > 'Initialize Data Adapter and Data Table Objects > > TempDA.Fill(TempDS, "Temp") > > TempDT = TempDS.Tables("Temp") 'Temp is the name of table > > > > > > 'Store to Temporary Table > > 'Start Connection > > If Cn.State = ConnectionState.Closed Then > > Call StartConnection() > > End If > > > > TempNewRow = TempDT.NewRow() > > TempNewRow("Pno") = NewPNo > > TempNewRow("PLName") = tab1_namepl > > > > 'Add the new row > > TempDT.Rows.Add(TempNewRow) > > > > 'Commit Changes > > TempDS.AcceptChanges() > > > > dsChanges = TempDS.GetChanges > > TempDA.Update(dsChanges, "Temp") > > > > 'Increment Permit Number > > NewPNo = NewPNo + 1 > > Cn.Close() > > > > If TempDS.HasChanges(DataRowState.Added) Then > > MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly, > > "Success") > > End If > > > > > > Please also let me know which method for "Saving" record is fast > > (non-SQL). > > > Hi,
dsChanges = TempDS.GetChanges TempDA.Update(dsChanges, "Temp") 'Commit Changes TempDS.AcceptChanges() Ken ---------------- Show quoteHide quote "RPK" <R**@discussions.microsoft.com> wrote in message news:1A3800C2-8815-45DD-89A4-57F1F5B2B308@microsoft.com... > Ken, > > Please illustrate the lines where the changes are needed. > > Thanks. > > ---------------------------------------------------------------- > > "Ken Tucker [MVP]" wrote: > >> Hi, >> >> When you call TempDS.AcceptChanges it marks all the records as >> unchanged. So dsChanges will not get any records. >> >> Ken >> --------------------- >> "RPK" <R**@discussions.microsoft.com> wrote in message >> news:4DB26F5B-4ECB-4D45-8307-3C5D02454BDC@microsoft.com... >> >I am using following code to Add New Record in a Table (Temp in this >> >case). >> >I >> > want to save new record with this method i.e., non-SQL. It is not >> > commiting >> > changes. The "Update" statement has errors. >> > >> > >> > 'Initialize Data Adapter and Data Table Objects >> > TempDA.Fill(TempDS, "Temp") >> > TempDT = TempDS.Tables("Temp") 'Temp is the name of table >> > >> > >> > 'Store to Temporary Table >> > 'Start Connection >> > If Cn.State = ConnectionState.Closed Then >> > Call StartConnection() >> > End If >> > >> > TempNewRow = TempDT.NewRow() >> > TempNewRow("Pno") = NewPNo >> > TempNewRow("PLName") = tab1_namepl >> > >> > 'Add the new row >> > TempDT.Rows.Add(TempNewRow) >> > >> > 'Commit Changes >> > TempDS.AcceptChanges() >> > >> > dsChanges = TempDS.GetChanges >> > TempDA.Update(dsChanges, "Temp") >> > >> > 'Increment Permit Number >> > NewPNo = NewPNo + 1 >> > Cn.Close() >> > >> > If TempDS.HasChanges(DataRowState.Added) Then >> > MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly, >> > "Success") >> > End If >> > >> > >> > Please also let me know which method for "Saving" record is fast >> > (non-SQL). >> >> >>
storing image in Access table
How can I read an XML string directly into a dataset without creating a file? Can I create windows form by using late binding? HTML in to readable/value accessible object what to do, what to do Text file printout in dos mode through VB.Net or DOS command from VB.Net Setup Project Help Displaying & Stabilizing PictureBox Contents passing a list as a parameter to a TableAdapter Fill method JAVASCRIPT IN ASP.NET |
|||||||||||||||||||||||