Results 1 to 15 of 15

Thread: simple DB

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    simple DB

    Hi ,
    Could anyone show me how to do simple operations (inserts , delete , update) against access db in disconnected mode .
    there are lots of confusing methods (datatable , datarow , dataset , dataadpter,datareader etc).I don't know from where to start .
    anyone would be of assistance guys!thanx

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    have a read of this.....it helped me.

    http://samples.gotdotnet.com/quickst...soverview.aspx

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Great nswan , but I was expecting some code .I've read lots of different topics about it but less code .thanx again

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    anyone plz has simple demonstration for that ?

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    click on the 'view source' link for each example to see some code!

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    the next pages seem to load forever .I coudn't open the other pages.

  7. #7
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    not a very good advert for asp.net hey!!!!

    http://www.developer.com/net/vb/arti...0926_1540311_1

    there is some code on the last page.

  8. #8

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    not really what I'm looking for though.Unfortunatly I've read that before. Well , basically how can I add some text to databse in disconnected mode ? that's all the story .
    and of course thanx for the help.

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    A lot of it is a matter of preference or how you are displaying the data. If you are using datarows and a dataset then you can use something like this:

    VB Code:
    1. 'get a blank new row from the table so it has all the structure
    2. Dim newRow as datarow=ds.Tables(0).NewRow
    3. 'fill the row with data
    4. newRow("Field")="Some data goes here"
    5. 'now the dataset has the new data but it is disconnected
    6. 'so the database itself doesn't so we use a dataadapter to
    7. 'update the actual database
    8. 'connect to the database
    9. cnn.Open()
    10. da.Update(ds.Tables(0))
    11. cnn.Close()

    Of course this assumes you have already setup the dataset and dataadapter. Setting up the dataadapter is just a matter of providing the SQL statements or Commands it will use to perform the various functions. So if you want it to Insert new rows make sure it has an InsertCommand, likewise for Updates, the UpdateCommand....

    You can also just add data directly to the database using Command objects (either SQL or OLEDB). This is a lot like the old vb6 way and doesn't require a dataset or datarows.

    VB Code:
    1. 'build sql statement
    2.         Dim sb As New System.Text.StringBuilder()
    3.         sb.Append("INSERT INTO MyTable (MyField1,MyField2) VALUES (")
    4.         'fill in values
    5.         sb.Append(value1 & ",")
    6.         sb.Append(value2 & ")")
    7.         'make command
    8.         Dim cmd As New OleDb.OleDbCommand(sb.ToString, cnn)
    9.         'open connection
    10.         cnn.Open()
    11.         'execute
    12.         cmd.ExecuteNonQuery()
    13.         cnn.Close()

    That should give you a push in the right direction. I didn't test it so I hope I didn't forget something.

  10. #10

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    two days of failed attempts . I tried Edneeis and others' ways but there is something I can't understand.
    so plz help .
    Attached Files Attached Files

  11. #11

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    guys plz . It's too easy but I couldn't figure it out ! plz

  12. #12
    Member EagleEye's Avatar
    Join Date
    May 2002
    Location
    South Carolina, USA
    Posts
    43
    Reinstalling VS.Net ... will look at it in a little while.
    Eagle Eye

    "Programming is easy ... when you are done."

  13. #13
    Member EagleEye's Avatar
    Join Date
    May 2002
    Location
    South Carolina, USA
    Posts
    43
    Please post your database you are using with the project. I have Office XP and cannot edit the Access 97 database you sent (which only has the 'URL' field in 'Table1'). Otherwise I will make an Access 2000 DB with the fields you have in your code (but then you won't be able to edit the table unless you have Access 2000 or greater).
    Eagle Eye

    "Programming is easy ... when you are done."

  14. #14
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Here is your project back I made a few corrections and commented them with HACK tasks.

  15. #15

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Edneeis you're great !
    thanx a lot !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width