Write to an Access database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Smlt?=

    #1

    Write to an Access database

    I have code that reads and parses a text file using a schema.ini file. Works
    great. When I see the dataGrid it's exactly what I want.

    Dim CString As String = _
    "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
    "Data Source=C:\;" & _
    "Extended Properties=""te xt;HDR=No;"""

    Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)

    TConnect.Open()

    Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
    837P.txt", TConnect)

    Dim ds As New DataSet("Banana s")

    da.Fill(ds)
    DataGridView1.D ataSource = ds.Tables(0)

    I now want to take this table from the dataGridVew and write it out to my
    Access database.

    I have code to connect to the db. I can run delete queries against it but I
    can't figure out how to add this data to it. I've been all over the internet
    and I get close but no joy.

    Here's the code I have for the Access half:

    Dim objConnection As New OleDbConnection (accessConnect)
    'Dim strSQL As String = "Select * INTO z FROM " & table & ";"
    Dim strSQL As String = "DELETE text_table.* FROM text_table;"
    Dim objCommand As New OleDbCommand(st rSQL, objConnection)
    Dim objDataAdapter As New OleDbDataAdapte r(objCommand)
    Dim objDataTable As New Data.DataTable( "text_table ")
    Dim objDataRow As DataRow
    Dim intRowsAffected As Integer

    Try
    'open db connection
    objConnection.O pen()
    intRowsAffected = objCommand.Exec uteNonQuery()

    Catch oledbexceptione rr As Exception
    MessageBox.Show (oledbexception err.Message)
    End Try

    objConnection.C lose()

    Is there a way to just tweak this code to get it to write my table to
    "text_table " in my db?


  • Jim

    #2
    Re: Write to an Access database

    To clarify: what I think I need is a way to construct the SQL to
    reference the ds.tables(0) below is something like "SELECT * INTO
    text_table FROM dsTable" Where Dim dsTable dataTable = ds.tables(0),
    but I can't get that to work.

    I saw on one helpful post that an SQL to update the db was all that's
    needed. HA!

    Jim

    P.S. I've seen the question asked in other posts but I've never seen a
    direct answer. Please don't send me off to a reference on the topic.
    That's what I've been looking at for the last 8 hours and still can't
    get it. Maybe its just me and its too late and I'm too tired. :-( oh
    oh... self pity is starting to creep in. I'm out of here.

    Jim wrote:
    I have code that reads and parses a text file using a schema.ini file. Works
    great. When I see the dataGrid it's exactly what I want.
    >
    Dim CString As String = _
    "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
    "Data Source=C:\;" & _
    "Extended Properties=""te xt;HDR=No;"""
    >
    Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
    >
    TConnect.Open()
    >
    Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
    837P.txt", TConnect)
    >
    Dim ds As New DataSet("Banana s")
    >
    da.Fill(ds)
    DataGridView1.D ataSource = ds.Tables(0)
    >
    I now want to take this table from the dataGridVew and write it out to my
    Access database.
    >
    I have code to connect to the db. I can run delete queries against it but I
    can't figure out how to add this data to it. I've been all over the internet
    and I get close but no joy.
    >
    Here's the code I have for the Access half:
    Dim dsTable dataTable = ds.tables(0)
    >
    Dim objConnection As New OleDbConnection (accessConnect)
    'Dim strSQL As String = "Select * INTO z FROM " & table & ";"
    Dim strSQL As String = "DELETE text_table.* FROM text_table;"
    Dim objCommand As New OleDbCommand(st rSQL, objConnection)
    Dim objDataAdapter As New OleDbDataAdapte r(objCommand)
    Dim objDataTable As New Data.DataTable( "text_table ")
    Dim objDataRow As DataRow
    Dim intRowsAffected As Integer
    >
    Try
    'open db connection
    objConnection.O pen()
    intRowsAffected = objCommand.Exec uteNonQuery()
    >
    Catch oledbexceptione rr As Exception
    MessageBox.Show (oledbexception err.Message)
    End Try
    >
    objConnection.C lose()
    >
    Is there a way to just tweak this code to get it to write my table to
    "text_table " in my db?
    >
    >

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Write to an Access database

      Jim,

      In Net you are mostly working with binded controls. The DataGridView is a
      complex databinded control.

      You can work with strongly typed datasets (datatable) and with non strongly
      typed ones, let say basic ones.

      In the area of the strongly typed datasets we see every time much more
      progress. As example in the time of Net 1.x everybody was talking here only
      about non strongly typed ones, now it becomes more and more strongly typed
      ones.

      However nothing wrong how you did it, however you have now to build your own
      Update, Insert and Delete SQL statemements.

      But you can also use the OleDBCommandbui lder a command wich is disliked by
      many people however is in my idea perfect as long as that your updates are
      as simple that they come in fact from a grid.

      http://msdn2.microsoft.com/en-us/lib...ndbuilder.aspx

      I hope this helps,

      Cor

      "Jim" <Jim@discussion s.microsoft.com schreef in bericht
      news:55F7658A-E81C-4ACD-8F0B-F756BD45F2D5@mi crosoft.com...
      >I have code that reads and parses a text file using a schema.ini file.
      >Works
      great. When I see the dataGrid it's exactly what I want.
      >
      Dim CString As String = _
      "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
      "Data Source=C:\;" & _
      "Extended Properties=""te xt;HDR=No;"""
      >
      Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
      >
      TConnect.Open()
      >
      Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
      837P.txt", TConnect)
      >
      Dim ds As New DataSet("Banana s")
      >
      da.Fill(ds)
      DataGridView1.D ataSource = ds.Tables(0)
      >
      I now want to take this table from the dataGridVew and write it out to my
      Access database.
      >
      I have code to connect to the db. I can run delete queries against it but
      I
      can't figure out how to add this data to it. I've been all over the
      internet
      and I get close but no joy.
      >
      Here's the code I have for the Access half:
      >
      Dim objConnection As New OleDbConnection (accessConnect)
      'Dim strSQL As String = "Select * INTO z FROM " & table & ";"
      Dim strSQL As String = "DELETE text_table.* FROM text_table;"
      Dim objCommand As New OleDbCommand(st rSQL, objConnection)
      Dim objDataAdapter As New OleDbDataAdapte r(objCommand)
      Dim objDataTable As New Data.DataTable( "text_table ")
      Dim objDataRow As DataRow
      Dim intRowsAffected As Integer
      >
      Try
      'open db connection
      objConnection.O pen()
      intRowsAffected = objCommand.Exec uteNonQuery()
      >
      Catch oledbexceptione rr As Exception
      MessageBox.Show (oledbexception err.Message)
      End Try
      >
      objConnection.C lose()
      >
      Is there a way to just tweak this code to get it to write my table to
      "text_table " in my db?
      >
      >

      Comment

      • Jim

        #4
        Re: Write to an Access database

        Cor,

        Thanks for the insight. I've looked at your reference and I'm still
        somewhat confused. I'm a newbie in .net. I've read other posts where
        it was said "just build the SQL statements". I can't see how to do that
        nor can I see how the OleDBCommandbui lder will help do that. I know I'm
        missing something simple here.

        Can someone give me a short example of what that SQL statement might
        look like based on my code below?

        Jim

        Cor Ligthert [MVP] wrote:
        Jim,
        >
        In Net you are mostly working with binded controls. The DataGridView is a
        complex databinded control.
        >
        You can work with strongly typed datasets (datatable) and with non strongly
        typed ones, let say basic ones.
        >
        In the area of the strongly typed datasets we see every time much more
        progress. As example in the time of Net 1.x everybody was talking here only
        about non strongly typed ones, now it becomes more and more strongly typed
        ones.
        >
        However nothing wrong how you did it, however you have now to build your own
        Update, Insert and Delete SQL statemements.
        >
        But you can also use the OleDBCommandbui lder a command wich is disliked by
        many people however is in my idea perfect as long as that your updates are
        as simple that they come in fact from a grid.
        >
        http://msdn2.microsoft.com/en-us/lib...ndbuilder.aspx
        >
        I hope this helps,
        >
        Cor
        >
        "Jim" <Jim@discussion s.microsoft.com schreef in bericht
        news:55F7658A-E81C-4ACD-8F0B-F756BD45F2D5@mi crosoft.com...
        >I have code that reads and parses a text file using a schema.ini file.
        >Works
        >great. When I see the dataGrid it's exactly what I want.
        >>
        > Dim CString As String = _
        > "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
        > "Data Source=C:\;" & _
        > "Extended Properties=""te xt;HDR=No;"""
        >>
        > Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
        >>
        > TConnect.Open()
        >>
        > Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
        >837P.txt", TConnect)
        >>
        > Dim ds As New DataSet("Banana s")
        >>
        > da.Fill(ds)
        > DataGridView1.D ataSource = ds.Tables(0)
        >>
        >I now want to take this table from the dataGridVew and write it out to my
        >Access database.
        >>
        >I have code to connect to the db. I can run delete queries against it but
        >I
        >can't figure out how to add this data to it. I've been all over the
        >internet
        >and I get close but no joy.
        >>
        >Here's the code I have for the Access half:
        >>
        >Dim objConnection As New OleDbConnection (accessConnect)
        > 'Dim strSQL As String = "Select * INTO z FROM " & table & ";"
        > Dim strSQL As String = "DELETE text_table.* FROM text_table;"
        > Dim objCommand As New OleDbCommand(st rSQL, objConnection)
        > Dim objDataAdapter As New OleDbDataAdapte r(objCommand)
        > Dim objDataTable As New Data.DataTable( "text_table ")
        > Dim objDataRow As DataRow
        > Dim intRowsAffected As Integer
        >>
        > Try
        > 'open db connection
        > objConnection.O pen()
        > intRowsAffected = objCommand.Exec uteNonQuery()
        >>
        > Catch oledbexceptione rr As Exception
        > MessageBox.Show (oledbexception err.Message)
        > End Try
        >>
        > objConnection.C lose()
        >>
        >Is there a way to just tweak this code to get it to write my table to
        >"text_table " in my db?
        >>
        >>
        >
        >

        Comment

        • dbahooker@hotmail.com

          #5
          Re: Write to an Access database

          CORRECTION!

          Jet shouldn't be used by anyone for any reason

          SERIOUS KID
          move to SQL Server


          On May 3, 5:07 pm, Jim <J...@discussio ns.microsoft.co mwrote:
          I have code that reads and parses a text file using a schema.ini file. Works
          great. When I see the dataGrid it's exactly what I want.
          >
          Dim CString As String = _
          "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
          "Data Source=C:\;" & _
          "Extended Properties=""te xt;HDR=No;"""
          >
          Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
          >
          TConnect.Open()
          >
          Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
          837P.txt", TConnect)
          >
          Dim ds As New DataSet("Banana s")
          >
          da.Fill(ds)
          DataGridView1.D ataSource = ds.Tables(0)
          >
          I now want to take this table from the dataGridVew and write it out to my
          Access database.
          >
          I have code to connect to the db. I can run delete queries against it but I
          can't figure out how to add this data to it. I've been all over the internet
          and I get close but no joy.
          >
          Here's the code I have for the Access half:
          >
          Dim objConnection As New OleDbConnection (accessConnect)
          'Dim strSQL As String = "Select * INTO z FROM " & table & ";"
          Dim strSQL As String = "DELETE text_table.* FROM text_table;"
          Dim objCommand As New OleDbCommand(st rSQL, objConnection)
          Dim objDataAdapter As New OleDbDataAdapte r(objCommand)
          Dim objDataTable As New Data.DataTable( "text_table ")
          Dim objDataRow As DataRow
          Dim intRowsAffected As Integer
          >
          Try
          'open db connection
          objConnection.O pen()
          intRowsAffected = objCommand.Exec uteNonQuery()
          >
          Catch oledbexceptione rr As Exception
          MessageBox.Show (oledbexception err.Message)
          End Try
          >
          objConnection.C lose()
          >
          Is there a way to just tweak this code to get it to write my table to
          "text_table " in my db?

          Comment

          • dbahooker@hotmail.com

            #6
            Re: Write to an Access database

            select from where

            or insert select
            or insert values

            or delete from table where

            or update table set




            On May 4, 6:22 am, Jim <joSmith...@Rem oveThisStuffNet scape.netwrote:
            Cor,
            >
            Thanks for the insight. I've looked at your reference and I'm still
            somewhat confused. I'm a newbie in .net. I've read other posts where
            it was said "just build the SQL statements". I can't see how to do that
            nor can I see how the OleDBCommandbui lder will help do that. I know I'm
            missing something simple here.
            >
            Can someone give me a short example of what that SQL statement might
            look like based on my code below?
            >
            Jim
            >
            >
            >
            Cor Ligthert [MVP] wrote:
            Jim,
            >
            In Net you are mostly working with binded controls. The DataGridView is a
            complex databinded control.
            >
            You can work with strongly typed datasets (datatable) and with non strongly
            typed ones, let say basic ones.
            >
            In the area of the strongly typed datasets we see every time much more
            progress. As example in the time of Net 1.x everybody was talking here only
            about non strongly typed ones, now it becomes more and more strongly typed
            ones.
            >
            However nothing wrong how you did it, however you have now to build your own
            Update, Insert and Delete SQL statemements.
            >
            But you can also use the OleDBCommandbui lder a command wich is disliked by
            many people however is in my idea perfect as long as that your updates are
            as simple that they come in fact from a grid.
            >>
            I hope this helps,
            >
            Cor
            >
            "Jim" <J...@discussio ns.microsoft.co mschreef in bericht
            news:55F7658A-E81C-4ACD-8F0B-F756BD45F2D5@mi crosoft.com...
            I have code that reads and parses a text file using a schema.ini file.
            Works
            great. When I see the dataGrid it's exactly what I want.
            >
            Dim CString As String = _
            "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
            "Data Source=C:\;" & _
            "Extended Properties=""te xt;HDR=No;"""
            >
            Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
            >
            TConnect.Open()
            >
            Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
            837P.txt", TConnect)
            >
            Dim ds As New DataSet("Banana s")
            >
            da.Fill(ds)
            DataGridView1.D ataSource = ds.Tables(0)
            >
            I now want to take this table from the dataGridVew and write it out to my
            Access database.
            >
            I have code to connect to the db. I can run delete queries against it but
            I
            can't figure out how to add this data to it. I've been all over the
            internet
            and I get close but no joy.
            >
            Here's the code I have for the Access half:
            >
            Dim objConnection As New OleDbConnection (accessConnect)
            'Dim strSQL As String = "Select * INTO z FROM " & table & ";"
            Dim strSQL As String = "DELETE text_table.* FROM text_table;"
            Dim objCommand As New OleDbCommand(st rSQL, objConnection)
            Dim objDataAdapter As New OleDbDataAdapte r(objCommand)
            Dim objDataTable As New Data.DataTable( "text_table ")
            Dim objDataRow As DataRow
            Dim intRowsAffected As Integer
            >
            Try
            'open db connection
            objConnection.O pen()
            intRowsAffected = objCommand.Exec uteNonQuery()
            >
            Catch oledbexceptione rr As Exception
            MessageBox.Show (oledbexception err.Message)
            End Try
            >
            objConnection.C lose()
            >
            Is there a way to just tweak this code to get it to write my table to
            "text_table " in my db?- Hide quoted text -
            >
            - Show quoted text -

            Comment

            • Jim

              #7
              Re: Write to an Access database

              That I could do. The problem is I'm working from:
              >>> Dim ds As New DataSet("Banana s")
              >>> da.Fill(ds)
              >>> DataGridView1.D ataSource = ds.Tables(0)
              See below for details. I can't figuer out how to reference the table.

              dbahooker@hotma il.com wrote:
              select from where
              >
              or insert select
              or insert values
              >
              or delete from table where
              >
              or update table set
              >
              >
              >
              >
              On May 4, 6:22 am, Jim <joSmith...@Rem oveThisStuffNet scape.netwrote:
              >Cor,
              >>
              >Thanks for the insight. I've looked at your reference and I'm still
              >somewhat confused. I'm a newbie in .net. I've read other posts where
              >it was said "just build the SQL statements". I can't see how to do that
              >nor can I see how the OleDBCommandbui lder will help do that. I know I'm
              >missing something simple here.
              >>
              >Can someone give me a short example of what that SQL statement might
              >look like based on my code below?
              >>
              >Jim
              >>
              >>
              >>
              >Cor Ligthert [MVP] wrote:
              >>Jim,
              >>In Net you are mostly working with binded controls. The DataGridView is a
              >>complex databinded control.
              >>You can work with strongly typed datasets (datatable) and with non strongly
              >>typed ones, let say basic ones.
              >>In the area of the strongly typed datasets we see every time much more
              >>progress. As example in the time of Net 1.x everybody was talking here only
              >>about non strongly typed ones, now it becomes more and more strongly typed
              >>ones.
              >>However nothing wrong how you did it, however you have now to build your own
              >>Update, Insert and Delete SQL statemements.
              >>But you can also use the OleDBCommandbui lder a command wich is disliked by
              >>many people however is in my idea perfect as long as that your updates are
              >>as simple that they come in fact from a grid.
              >>http://msdn2.microsoft.com/en-us/lib...edb.oledbcomma...
              >>I hope this helps,
              >>Cor
              >>"Jim" <J...@discussio ns.microsoft.co mschreef in bericht
              >>news:55F765 8A-E81C-4ACD-8F0B-F756BD45F2D5@mi crosoft.com...
              >>>I have code that reads and parses a text file using a schema.ini file.
              >>>Works
              >>>great. When I see the dataGrid it's exactly what I want.
              >>> Dim CString As String = _
              >
              >>> "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
              >>> "Data Source=C:\;" & _
              >>> "Extended Properties=""te xt;HDR=No;"""
              >>> Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
              >>> TConnect.Open()
              >>> Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
              >>>837P.txt", TConnect)
              >>> Dim ds As New DataSet("Banana s")
              >>> da.Fill(ds)
              >>> DataGridView1.D ataSource = ds.Tables(0)
              >>>I now want to take this table from the dataGridVew and write it out to my
              >>>Access database.
              >>>I have code to connect to the db. I can run delete queries against it but
              >>>I
              >>>can't figure out how to add this data to it. I've been all over the
              >>>internet
              >>>and I get close but no joy.
              >>>Here's the code I have for the Access half:
              >>>Dim objConnection As New OleDbConnection (accessConnect)
              >>> 'Dim strSQL As String = "Select * INTO z FROM " & table & ";"
              >>> Dim strSQL As String = "DELETE text_table.* FROM text_table;"
              >>> Dim objCommand As New OleDbCommand(st rSQL, objConnection)
              >>> Dim objDataAdapter As New OleDbDataAdapte r(objCommand)
              >>> Dim objDataTable As New Data.DataTable( "text_table ")
              >>> Dim objDataRow As DataRow
              >>> Dim intRowsAffected As Integer
              >>> Try
              >>> 'open db connection
              >>> objConnection.O pen()
              >>> intRowsAffected = objCommand.Exec uteNonQuery()
              >>> Catch oledbexceptione rr As Exception
              >>> MessageBox.Show (oledbexception err.Message)
              >>> End Try
              >>> objConnection.C lose()
              >>>Is there a way to just tweak this code to get it to write my table to
              >>>"text_tabl e" in my db?- Hide quoted text -
              >- Show quoted text -
              >
              >

              Comment

              • dbahooker@hotmail.com

                #8
                Re: Write to an Access database

                you don't need an INTO statement if you're just referencing a sql
                statement in ADO.net

                an INTO statement will run a 'make table query'


                hth



                On May 4, 3:33 pm, Jim <joSmith...@Rem oveThisStuffNet scape.netwrote:
                That I could do. The problem is I'm working from:
                >>> Dim ds As New DataSet("Banana s")
                >>> da.Fill(ds)
                >>> DataGridView1.D ataSource = ds.Tables(0)
                >
                See below for details. I can't figuer out how to reference the table.
                >
                >
                >
                dbahoo...@hotma il.com wrote:
                select from where
                >
                or insert select
                or insert values
                >
                or delete from table where
                >
                or update table set
                >
                On May 4, 6:22 am, Jim <joSmith...@Rem oveThisStuffNet scape.netwrote:
                Cor,
                >
                Thanks for the insight. I've looked at your reference and I'm still
                somewhat confused. I'm a newbie in .net. I've read other posts where
                it was said "just build the SQL statements". I can't see how to do that
                nor can I see how the OleDBCommandbui lder will help do that. I know I'm
                missing something simple here.
                >
                Can someone give me a short example of what that SQL statement might
                look like based on my code below?
                >
                Jim
                >
                Cor Ligthert [MVP] wrote:
                >Jim,
                >In Net you are mostly working with binded controls. The DataGridView is a
                >complex databinded control.
                >You can work with strongly typed datasets (datatable) and with non strongly
                >typed ones, let say basic ones.
                >In the area of the strongly typed datasets we see every time much more
                >progress. As example in the time of Net 1.x everybody was talking here only
                >about non strongly typed ones, now it becomes more and more strongly typed
                >ones.
                >However nothing wrong how you did it, however you have now to build your own
                >Update, Insert and Delete SQL statemements.
                >But you can also use the OleDBCommandbui lder a command wich is disliked by
                >many people however is in my idea perfect as long as that your updates are
                >as simple that they come in fact from a grid.
                >>http://msdn2.microsoft.com/en-us/lib...edb.oledbcomma...
                >I hope this helps,
                >Cor
                >"Jim" <J...@discussio ns.microsoft.co mschreef in bericht
                >>news:55F765 8A-E81C-4ACD-8F0B-F756BD45F2D5@mi crosoft.com...
                >>I have code that reads and parses a text file using a schema.ini file.
                >>Works
                >>great. When I see the dataGrid it's exactly what I want.
                >> Dim CString As String = _
                >
                >> "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                >> "Data Source=C:\;" & _
                >> "Extended Properties=""te xt;HDR=No;"""
                >> Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
                >> TConnect.Open()
                >> Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
                >>837P.txt", TConnect)
                >> Dim ds As New DataSet("Banana s")
                >> da.Fill(ds)
                >> DataGridView1.D ataSource = ds.Tables(0)
                >>I now want to take this table from the dataGridVew and write it out to my
                >>Access database.
                >>I have code to connect to the db. I can run delete queries against it but
                >>I
                >>can't figure out how to add this data to it. I've been all over the
                >>internet
                >>and I get close but no joy.
                >>Here's the code I have for the Access half:
                >>Dim objConnection As New OleDbConnection (accessConnect)
                >> 'Dim strSQL As String = "Select * INTO z FROM " & table & ";"
                >> Dim strSQL As String = "DELETE text_table.* FROM text_table;"
                >> Dim objCommand As New OleDbCommand(st rSQL, objConnection)
                >> Dim objDataAdapter As New OleDbDataAdapte r(objCommand)
                >> Dim objDataTable As New Data.DataTable( "text_table ")
                >> Dim objDataRow As DataRow
                >> Dim intRowsAffected As Integer
                >> Try
                >> 'open db connection
                >> objConnection.O pen()
                >> intRowsAffected = objCommand.Exec uteNonQuery()
                >> Catch oledbexceptione rr As Exception
                >> MessageBox.Show (oledbexception err.Message)
                >> End Try
                >> objConnection.C lose()
                >>Is there a way to just tweak this code to get it to write my table to
                >>"text_table " in my db?- Hide quoted text -
                - Show quoted text -- Hide quoted text -
                >
                - Show quoted text -

                Comment

                • Jim

                  #9
                  Re: Write to an Access database

                  OK so what DO I need?

                  Coming from here:

                  <snip==== This Works Fine ====
                  Dim CString As String = _
                  "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                  "Data Source=C:\;" & _
                  "Extended Properties=""te xt;HDR=No;"""
                  Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
                  TConnect.Open()
                  Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
                  837P.txt", TConnect)
                  Dim ds As New DataSet("Banana s")
                  da.Fill(ds)
                  DataGridView1.D ataSource = ds.Tables(0)
                  <snip>

                  How do I get that ds.tables(0) into a table here?
                  Dim AString As String = _
                  "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                  "Data Source=C:\abc.m db;"


                  Sorry I'm the newbie. I just can't see how to that dataset(Bananas ).

                  dbahooker@hotma il.com wrote:
                  you don't need an INTO statement if you're just referencing a sql
                  statement in ADO.net
                  >
                  an INTO statement will run a 'make table query'
                  >
                  >
                  hth
                  >

                  Comment

                  • dbahooker@hotmail.com

                    #10
                    Re: Write to an Access database

                    you just need to fire a SQL Statemnet

                    Dim strSql as string
                    strSql = "BULK INSERT TblName FROM 'C:\MyPath.txt'

                    You can lookup more about it in SQL Server books online




                    On May 7, 4:49 pm, Jim <joSmith...@Rem oveThisStuffNet scape.netwrote:
                    OK so what DO I need?
                    >
                    Coming from here:
                    >
                    <snip==== This Works Fine ====
                    Dim CString As String = _
                    "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                    "Data Source=C:\;" & _
                    "Extended Properties=""te xt;HDR=No;"""
                    Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
                    TConnect.Open()
                    Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
                    837P.txt", TConnect)
                    Dim ds As New DataSet("Banana s")
                    da.Fill(ds)
                    DataGridView1.D ataSource = ds.Tables(0)
                    <snip>
                    >
                    How do I get that ds.tables(0) into a table here?
                    Dim AString As String = _
                    "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                    "Data Source=C:\abc.m db;"
                    >
                    Sorry I'm the newbie. I just can't see how to that dataset(Bananas ).
                    >
                    >
                    >
                    dbahoo...@hotma il.com wrote:
                    you don't need an INTO statement if you're just referencing a sql
                    statement in ADO.net
                    >
                    an INTO statement will run a 'make table query'
                    >
                    hth- Hide quoted text -
                    >
                    - Show quoted text -

                    Comment

                    • dbahooker@hotmail.com

                      #11
                      Re: Write to an Access database

                      and about the whole data adapter thing; I don't believe in ADO.net--
                      It doesnt' allow you to share a connection (two recordsets on the same
                      connection) and it doesn't allow you to keep a connection open.

                      To me? That's a worthless Data Access Library.
                      I'd rather use DAO or ADO Classic




                      On May 7, 4:49 pm, Jim <joSmith...@Rem oveThisStuffNet scape.netwrote:
                      OK so what DO I need?
                      >
                      Coming from here:
                      >
                      <snip==== This Works Fine ====
                      Dim CString As String = _
                      "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                      "Data Source=C:\;" & _
                      "Extended Properties=""te xt;HDR=No;"""
                      Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
                      TConnect.Open()
                      Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
                      837P.txt", TConnect)
                      Dim ds As New DataSet("Banana s")
                      da.Fill(ds)
                      DataGridView1.D ataSource = ds.Tables(0)
                      <snip>
                      >
                      How do I get that ds.tables(0) into a table here?
                      Dim AString As String = _
                      "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                      "Data Source=C:\abc.m db;"
                      >
                      Sorry I'm the newbie. I just can't see how to that dataset(Bananas ).
                      >
                      >
                      >
                      dbahoo...@hotma il.com wrote:
                      you don't need an INTO statement if you're just referencing a sql
                      statement in ADO.net
                      >
                      an INTO statement will run a 'make table query'
                      >
                      hth- Hide quoted text -
                      >
                      - Show quoted text -

                      Comment

                      • RobinS

                        #12
                        Re: Write to an Access database

                        Try posting your question to microsoft.publi c.dotnet.framew ork.adonet.

                        And watch out for advice from dbahooker; he is a known troll in this
                        newsgroup.

                        Robin S.
                        =============== ========
                        "Jim" <joSmith2im@Rem oveThisStuffNet scape.netwrote in message
                        news:wYudnTjl89 iHJqLbnZ2dnUVZ_ tWhnZ2d@massill oncabletv.com.. .
                        OK so what DO I need?
                        >
                        Coming from here:
                        >
                        <snip==== This Works Fine ====
                        Dim CString As String = _
                        "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                        "Data Source=C:\;" & _
                        "Extended Properties=""te xt;HDR=No;"""
                        Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
                        TConnect.Open()
                        Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
                        837P.txt", TConnect)
                        Dim ds As New DataSet("Banana s")
                        da.Fill(ds)
                        DataGridView1.D ataSource = ds.Tables(0)
                        <snip>
                        >
                        How do I get that ds.tables(0) into a table here?
                        Dim AString As String = _
                        "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                        "Data Source=C:\abc.m db;"
                        >
                        >
                        Sorry I'm the newbie. I just can't see how to that dataset(Bananas ).
                        >
                        dbahooker@hotma il.com wrote:
                        >you don't need an INTO statement if you're just referencing a sql
                        >statement in ADO.net
                        >>
                        >an INTO statement will run a 'make table query'
                        >>
                        >>
                        >hth
                        >>

                        Comment

                        • dbahooker@hotmail.com

                          #13
                          Re: Write to an Access database

                          ROFL

                          a known troll.. like it is a bad thign

                          I stand up for freedom of speech and freedom from buggy software
                          I stand up for a consistent marketing message

                          and I stand up for VB

                          everyone else around here is a big fat lazy wuss.. oh are the widdle
                          baby programmers AFWAID OF DEMANDING EXCELLENCE?





                          On May 20, 10:36 am, "RobinS" <Rob...@NoSpam. yah.nonewrote:
                          Try posting your question to microsoft.publi c.dotnet.framew ork.adonet.
                          >
                          And watch out for advice from dbahooker; he is a known troll in this
                          newsgroup.
                          >
                          Robin S.
                          =============== ========"Jim" <joSmith...@Rem oveThisStuffNet scape.netwrote in message
                          >
                          news:wYudnTjl89 iHJqLbnZ2dnUVZ_ tWhnZ2d@massill oncabletv.com.. .
                          >
                          >
                          >
                          OK so what DO I need?
                          >
                          Coming from here:
                          >
                          <snip==== This Works Fine ====
                          Dim CString As String = _
                          "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                          "Data Source=C:\;" & _
                          "Extended Properties=""te xt;HDR=No;"""
                          Dim TConnect As New System.Data.Ole Db.OleDbConnect ion(CString)
                          TConnect.Open()
                          Dim da As New System.Data.Ole Db.OleDbDataAda pter("Select * from
                          837P.txt", TConnect)
                          Dim ds As New DataSet("Banana s")
                          da.Fill(ds)
                          DataGridView1.D ataSource = ds.Tables(0)
                          <snip>
                          >
                          How do I get that ds.tables(0) into a table here?
                          Dim AString As String = _
                          "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                          "Data Source=C:\abc.m db;"
                          >
                          Sorry I'm the newbie. I just can't see how to that dataset(Bananas ).
                          >
                          dbahoo...@hotma il.com wrote:
                          you don't need an INTO statement if you're just referencing a sql
                          statement in ADO.net
                          >
                          an INTO statement will run a 'make table query'
                          >
                          hth- Hide quoted text -
                          >
                          - Show quoted text -

                          Comment

                          Working...