Discussion:
Dataset updating
(too old to reply)
UsenetUser
2009-07-25 08:23:47 UTC
Permalink
Can someone tell me what the problem is with this? The right values
are shown from the debug lines but the values are not saved. There is
no error. The source table has a primary key. The examples in the help
system do not indicate that beginedit, endedit or acceptchanges, or
other updating commands are necessary, but I have tried using the
first 3 as well.

Thanks.

Sub stest()
Dim conn As New SqlConnection(strConn) 'PB
Dim DSWriteBooking As DataSet = New DataSet
Dim strSQLWrite As String = "SELECT * FROM tblBookingW1"
Dim adpWrite As SqlDataAdapter = New
SqlDataAdapter(strSQLWrite, conn)
Dim EditRow() As DataRow
Try

adpWrite.Fill(DSWriteBooking, "tblBookingW1")
'Returns 10 rows
EditRow = DSWriteBooking.Tables(0).Select("PIDS1 = 0")
Debug.Print(EditRow(0)(1).ToString) '0
EditRow(0)(1) = 99
Debug.Print(EditRow(0)(1).ToString) '99
conn.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
conn = Nothing
adpWrite = Nothing
End Try
End Sub
UsenetUser
2009-07-25 09:20:43 UTC
Permalink
Solved. Had to add:
adpWrite.Update(DSWriteBooking.Tables(0))
Post by UsenetUser
Can someone tell me what the problem is with this? The right values
are shown from the debug lines but the values are not saved. There is
no error. The source table has a primary key. The examples in the help
system do not indicate that beginedit, endedit or acceptchanges, or
other updating commands are necessary, but I have tried using the
first 3 as well.
Thanks.
Sub stest()
Dim conn As New SqlConnection(strConn) 'PB
Dim DSWriteBooking As DataSet = New DataSet
Dim strSQLWrite As String = "SELECT * FROM tblBookingW1"
Dim adpWrite As SqlDataAdapter = New
SqlDataAdapter(strSQLWrite, conn)
Dim EditRow() As DataRow
Try
adpWrite.Fill(DSWriteBooking, "tblBookingW1")
'Returns 10 rows
EditRow = DSWriteBooking.Tables(0).Select("PIDS1 = 0")
Debug.Print(EditRow(0)(1).ToString) '0
EditRow(0)(1) = 99
Debug.Print(EditRow(0)(1).ToString) '99
conn.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
conn = Nothing
adpWrite = Nothing
End Try
End Sub
UsenetUser
2009-07-25 09:33:58 UTC
Permalink
F**k! This is the least intutive software I have come across in a long
time!

Also need:
Dim myDataRowsCommandBuilder As SqlCommandBuilder = New
SqlCommandBuilder(adpWrite)
as well as :
adpWrite.Update(DSWriteBooking.Tables(0))
Then it all works!
Post by UsenetUser
Can someone tell me what the problem is with this? The right values
are shown from the debug lines but the values are not saved. There is
no error. The source table has a primary key. The examples in the help
system do not indicate that beginedit, endedit or acceptchanges, or
other updating commands are necessary, but I have tried using the
first 3 as well.
Thanks.
Sub stest()
Dim conn As New SqlConnection(strConn) 'PB
Dim DSWriteBooking As DataSet = New DataSet
Dim strSQLWrite As String = "SELECT * FROM tblBookingW1"
Dim adpWrite As SqlDataAdapter = New
SqlDataAdapter(strSQLWrite, conn)
Dim EditRow() As DataRow
Try
adpWrite.Fill(DSWriteBooking, "tblBookingW1")
'Returns 10 rows
EditRow = DSWriteBooking.Tables(0).Select("PIDS1 = 0")
Debug.Print(EditRow(0)(1).ToString) '0
EditRow(0)(1) = 99
Debug.Print(EditRow(0)(1).ToString) '99
conn.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
conn = Nothing
adpWrite = Nothing
End Try
End Sub
Eric
2009-07-28 13:55:09 UTC
Permalink
Post by UsenetUser
This is the least intutive software I have come across in a long
time!
It sounds like you're a novice at this language, as I am.
As I'm trying to teach the language to myself, I've found it confusing. I
imported data to a tableadapter and thought the tableadapter was making a
copy of the data which I would have to set back to the table interfacing
object to update the database, but instead the tableadapter was a link to
the data through the object it got the data from, so it actually updated the
database when I made changes to the tableadapter. This actually made the
code simpler, but baffled me when I tried to assign the data from the
tableadapter back to the object it came from and execute it's update method
and it actually undid the changes.

I might be missing something, but I'm finding this part frustrating.. I
created a database from the VB.Net IDE (.mdf file). Then I had to add it to
my project to be able to reference it in my VB.Net program. I told it to
use the select * to pull in all fields. Now if I make changes to the
database table structures, I have to manually update the database reference
in the project to match.
UsenetUser
2009-08-02 03:36:22 UTC
Permalink
Yes, Eric, I am a novice for sure with VB.NET, but have been
developing databases in Access professionally for 15 years. VB/DOT NET
is extremely powerful, I can see that - but so many things that are
trival in Access, and I don't think i it is just because I am
familiar with them and not so with dotnet, are very, very time
consuming and awkward in this environment in good part because they
are highly unintuitive.

This software is really tough to learn on one's own. I mean, how could
anyone know that that line "Dim myDataRowsCommandBuilder As
SqlCommandBuilder = New SqlCommandBuilder(adpWrite) would be required
to return records in my procedure? There is no *obvious* logic to it.

Still, I want this application to be completely free standing, - not
have to include Access runtime, so I will do it in VB.NET and in fact
most of the functionality is in place now. BUT is it ever ugly
compared to an Access 2007 app! So that will be my next major
challenge with it - to try and make it a bit sexier, so to speak.

Good luck with yours!

Peter
Post by Eric
Post by UsenetUser
This is the least intutive software I have come across in a long
time!
It sounds like you're a novice at this language, as I am.
As I'm trying to teach the language to myself, I've found it confusing. I
imported data to a tableadapter and thought the tableadapter was making a
copy of the data which I would have to set back to the table interfacing
object to update the database, but instead the tableadapter was a link to
the data through the object it got the data from, so it actually updated the
database when I made changes to the tableadapter. This actually made the
code simpler, but baffled me when I tried to assign the data from the
tableadapter back to the object it came from and execute it's update method
and it actually undid the changes.
I might be missing something, but I'm finding this part frustrating.. I
created a database from the VB.Net IDE (.mdf file). Then I had to add it to
my project to be able to reference it in my VB.Net program. I told it to
use the select * to pull in all fields. Now if I make changes to the
database table structures, I have to manually update the database reference
in the project to match.
Eric
2009-08-03 14:04:45 UTC
Permalink
I've written programs in a bunch of different languages and I would have to
say there is at least something in every language which is not intuitive if
you're not an expert on the language. If you think VB.Net has a hard syntax
to understand, try writing an assembler program.

The robustness of VB.Net adds to the difficulty of the syntax, since it is
able to communicate with any sort of data source. For the application I'm
attempting to create, I used the built in database (which creates a .mdf
file) instead of the SQL connection because it seemed simpler for a simple
program which will only be used by one machine. I think the code should
always be more readable if you use the tools it comes with (ie the database
file). I also wanted the code completion and type checking to be able to
use a field name to access a table field from the database rather than
telling it the field name in a string literal. The IDE also has some
wizards for connecting data which insert some of the cryptic code for you.

I would imagine most programming languages are tough to learn on your own
from scratch. MS does provide some samples and tutorials to get you
started. If you can't figure out how to do what you need from samples and
tutorials you can find online, you might want to search online for a class
or a good book if you're serious about learning and plan to use the language
for more than one simple program.
Post by UsenetUser
Yes, Eric, I am a novice for sure with VB.NET, but have been
developing databases in Access professionally for 15 years. VB/DOT NET
is extremely powerful, I can see that - but so many things that are
trival in Access, and I don't think i it is just because I am
familiar with them and not so with dotnet, are very, very time
consuming and awkward in this environment in good part because they
are highly unintuitive.
This software is really tough to learn on one's own. I mean, how could
anyone know that that line "Dim myDataRowsCommandBuilder As
SqlCommandBuilder = New SqlCommandBuilder(adpWrite) would be required
to return records in my procedure? There is no *obvious* logic to it.
Still, I want this application to be completely free standing, - not
have to include Access runtime, so I will do it in VB.NET and in fact
most of the functionality is in place now. BUT is it ever ugly
compared to an Access 2007 app! So that will be my next major
challenge with it - to try and make it a bit sexier, so to speak.
Good luck with yours!
Peter
Post by Eric
Post by UsenetUser
This is the least intutive software I have come across in a long
time!
It sounds like you're a novice at this language, as I am.
As I'm trying to teach the language to myself, I've found it confusing. I
imported data to a tableadapter and thought the tableadapter was making a
copy of the data which I would have to set back to the table interfacing
object to update the database, but instead the tableadapter was a link to
the data through the object it got the data from, so it actually updated the
database when I made changes to the tableadapter. This actually made the
code simpler, but baffled me when I tried to assign the data from the
tableadapter back to the object it came from and execute it's update method
and it actually undid the changes.
I might be missing something, but I'm finding this part frustrating.. I
created a database from the VB.Net IDE (.mdf file). Then I had to add it to
my project to be able to reference it in my VB.Net program. I told it to
use the select * to pull in all fields. Now if I make changes to the
database table structures, I have to manually update the database reference
in the project to match.
UsenetUser
2009-08-06 08:07:56 UTC
Permalink
Post by Eric
I've written programs in a bunch of different languages and I would have to
say there is at least something in every language which is not intuitive if
you're not an expert on the language.
I don't think I said any language is 100% intutive, but I found VB/VBA
far, far more intiutive than VB.NET. I will acknowledge that perhaps
that is just me - I only have my own experience to go on.

If you think VB.Net has a hard syntax
Post by Eric
to understand, try writing an assembler program.
Yes, well, that is why we are mostly not writing programs at machine
level any more: beause it is not intuitive, not efficient, not
productive and while there might be some lingering nostalgia, I expect
you and others regard working in assembly as the 'bad old days' or you
would still be doing it. It's interesting that you choose to compare
VB.NET to it.
Post by Eric
The robustness of VB.Net adds to the difficulty of the syntax, since it is
able to communicate with any sort of data source.
I didn't say, nor do I believe, that intuitiveness is the be all and
end all of any RAD software, but you definitely chose the right word
with 'baffled' in describing your own problem. To me, that means 'you
can't get there from here' in the sense there is really no way to
figure out a solution. You have to research for one or ask someone
rather than use logic and/or trial and error. That is part of being
'non-intuitive', and VB.NET is too often baffling in the extreme.

I agree, though, it is extremely powerful - 'robust' - I am not so
sure about that. I've had lots of DOTNET programs crash on me.
Post by Eric
attempting to create, I used the built in database (which creates a .mdf
file) instead of the SQL connection because it seemed simpler for a simple
program which will only be used by one machine. I think the code should
always be more readable if you use the tools it comes with (ie the database
file). I also wanted the code completion and type checking to be able to
use a field name to access a table field from the database rather than
telling it the field name in a string literal. The IDE also has some
wizards for connecting data which insert some of the cryptic code for you.
I would imagine most programming languages are tough to learn on your own
from scratch.
I would rate VB at something less than 'tough' and VB.NET at
'impossible' without classroom study or online assistance of some kind
whether it be Usenet, forums, sample code or the like. Books would
not be enough unless you had a room full of them.

MS does provide some samples and tutorials to get you
Post by Eric
started. If you can't figure out how to do what you need from samples and
tutorials you can find online, you might want to search online for a class
or a good book if you're serious about learning and plan to use the language
for more than one simple program.
Are you being sarcastic? I mean, do you think that never would have
occurred to me, or anyone posting here, for that matter?

Loading...