Results 1 to 6 of 6

Thread: Someone please help me

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108

    Unhappy Someone please help me

    i got a problem to insert my data into my Access database

    i need to enter 8 data into my database using the the command like below but it give me error what is the problem ?

    ==============================================
    Private Sub SaveDB(ByVal TableStr As String)

    Dim sql = "SELECT * FROM " & TableStr
    Dim MyAdapter As New OleDb.OleDbDataAdapter(sql, conn)
    Dim builder As New OleDbCommandBuilder(MyAdapter)
    Dim mydataset As New DataSet

    MyAdapter.Fill(mydataset, TableStr)

    Dim MyDataRow As DataRow = mydataset.Tables(TableStr).NewRow
    MyDataRow(0) = Me.tablenumber.Text
    MyDataRow(1) = Me.cname.Text
    MyDataRow(2) = Me.chp.Text
    MyDataRow(3) = Me.carrivetime.Text
    MyDataRow(4) = Me.totcustomer.Text
    MyDataRow(5) = Me.timing.Text
    MyDataRow(6) = Me.day.Text
    MyDataRow(7) = Me.month.Text
    MyDataRow(8) = Me.year.Text

    mydataset.Tables(TableStr).Rows.Add(MyDataRow)
    MyAdapter.Update(mydataset, TableStr)
    conn.Close()

    MyAdapter = Nothing
    MessageBox.Show("Data Saved..")

    =========================================

    is the any problem for my code ??????
    or one time only can add 5 data ???
    coz i delete the code until MyDataRow(5) = Me.timing.Text
    and delete the 6,7,8 it can work
    =========================================

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    How many columns in that table in the database file ?and what does the error say ?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108

    Unhappy help ~~~

    before got any error, inside my table got 5 field
    than is tablenumber,name, handphone, arrivetime, totalcustomer and also timing.

    after that i run this system, it can work

    after that i add in 3 more field that is day, month and year

    after that i run the system and it come up an error ~~


  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    First off , change the field names (day , month and year) to something else (e.g : _day , _month , _year) .

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi ninjaX

    Pirate is probably spot-on. (Not that I would suggest he is ever anything else) You must avoid using reserved words as column names in the database
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108

    Talking thanx ~~~



    thank you
    i can add my data already ~~
    thanx for urs guy help

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