Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. help

help

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasejsonhelp
13 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R rajulama

    hi, I am Rana I am using vb.net to accomplish following task: 1) read a csv file from hard disc 2) display it on DataGridView 3) use the datagridview to update an existing access dataset table which has exactly same number of fileds as input csv file displayed in datagridview 4) add query to the updated datset table 5) exporting the result to a text file So far I cud only hab done until step 2. I desperately need help on rest of 3 steps. Here is my code: Code Block: Imports System.IO Imports System.Data Imports System.Data.SqlClient Imports System.Data.OleDb Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If OpenFileDialog1.ShowDialog(Me) = DialogResult.OK Then Dim fi As New FileInfo(OpenFileDialog1.FileName) Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Text;Data Source=" & fi.DirectoryName Dim objConn As New OleDbConnection(sConnectionString) Dim objDataSet As DataSet = New DataSet() objConn.Open() Dim objCmdSelect As New OleDbCommand("SELECT * FROM " & fi.Name, objConn) Dim objAdapter1 As New OleDbDataAdapter objAdapter1.SelectCommand = objCmdSelect objAdapter1.Fill(objDataSet, "test") DataGridView1.DataSource = objDataSet.Tables(0).DefaultView objConn.Close() End If End Sub End Class Please help me on how i can do above three things ASAP.

    D Offline
    D Offline
    Dave Kreskowiak
    wrote on last edited by
    #2

    Sorry, but this has "homework assignment" written all over it. We're not going to write your code for you. You wouldn't learn anything that way. Everything you need has already been covered in your class.

    A guide to posting questions on CodeProject[^]
    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
         2006, 2007, 2008

    R 1 Reply Last reply
    0
    • D Dave Kreskowiak

      Sorry, but this has "homework assignment" written all over it. We're not going to write your code for you. You wouldn't learn anything that way. Everything you need has already been covered in your class.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      R Offline
      R Offline
      rajulama
      wrote on last edited by
      #3

      Hello Dave Kreskowiak, please believe me its not a homework assignment. actually I am doing it as a part of the development. I have been trying : objAdapter1.Update(Me.Db1DataSet.Sheet1) but its not working. I just want your help on updating the database with this datgridview that's all. Rest I can do. Please help me!

      M K Y 3 Replies Last reply
      0
      • R rajulama

        Hello Dave Kreskowiak, please believe me its not a homework assignment. actually I am doing it as a part of the development. I have been trying : objAdapter1.Update(Me.Db1DataSet.Sheet1) but its not working. I just want your help on updating the database with this datgridview that's all. Rest I can do. Please help me!

        M Offline
        M Offline
        MidwestLimey
        wrote on last edited by
        #4

        rajulama wrote:

        I just want your help on updating the database

        A word of advice, the verb to Want is too abrasive to use when you are the one making a request from a position of weakness. It's better to use the subjective, i.e. "would like". Same principal I know applies in Spanish and German and I would expect to be fairly universal. Put simply it's the polite way to make a request of somebody you have no authority over. Not that it'll help you here, mind. Also, for the love of God, use a decent naming system!

        10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011

        R 1 Reply Last reply
        0
        • M MidwestLimey

          rajulama wrote:

          I just want your help on updating the database

          A word of advice, the verb to Want is too abrasive to use when you are the one making a request from a position of weakness. It's better to use the subjective, i.e. "would like". Same principal I know applies in Spanish and German and I would expect to be fairly universal. Put simply it's the polite way to make a request of somebody you have no authority over. Not that it'll help you here, mind. Also, for the love of God, use a decent naming system!

          10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011

          R Offline
          R Offline
          rajulama
          wrote on last edited by
          #5

          sorry, I would be really grateful to you if you could help me. Please don't mind. Help me out, please!

          J 1 Reply Last reply
          0
          • R rajulama

            sorry, I would be really grateful to you if you could help me. Please don't mind. Help me out, please!

            J Offline
            J Offline
            Jon_Boy
            wrote on last edited by
            #6

            MidwestLimey was correct and you're still not quite getting it. It's not polite to ask for help and then in the same request demand it with an exclamation mark. So lets practice as if you were going to ask for help from Dave, you could try kissing his a$$ a little like: "Dave the almighty who rules next to Xerxes - could you find it in your gracious heart to feel pity upon my disgraced soul and help me with my problem? I am nothing without your assistance and bow before your presence." Or...........you could simply ask for help without it demanding, caps, or !s. Your problem does kind of look like a homework assignment.

            Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

            D 1 Reply Last reply
            0
            • J Jon_Boy

              MidwestLimey was correct and you're still not quite getting it. It's not polite to ask for help and then in the same request demand it with an exclamation mark. So lets practice as if you were going to ask for help from Dave, you could try kissing his a$$ a little like: "Dave the almighty who rules next to Xerxes - could you find it in your gracious heart to feel pity upon my disgraced soul and help me with my problem? I am nothing without your assistance and bow before your presence." Or...........you could simply ask for help without it demanding, caps, or !s. Your problem does kind of look like a homework assignment.

              Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #7

              Jon_Boy wrote:

              "Dave the almighty who rules next to Xerxes - could you find it in your gracious heart to feel pity upon my disgraced soul and help me with my problem? I am nothing without your assistance and bow before your presence."

              OK, OK, I don't need to be wiping your lipstick off my ass! :-D

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008

              L 1 Reply Last reply
              0
              • R rajulama

                Hello Dave Kreskowiak, please believe me its not a homework assignment. actually I am doing it as a part of the development. I have been trying : objAdapter1.Update(Me.Db1DataSet.Sheet1) but its not working. I just want your help on updating the database with this datgridview that's all. Rest I can do. Please help me!

                K Offline
                K Offline
                Kschuler
                wrote on last edited by
                #8

                rajulama wrote:

                but its not working

                If you want help, you have to give more information. What isn't working? What error message are you getting? Show us what code you have so far. We're not going to do your work for you, but if you have a specific problem we can try to point you in the right direction to get help.

                R 1 Reply Last reply
                0
                • K Kschuler

                  rajulama wrote:

                  but its not working

                  If you want help, you have to give more information. What isn't working? What error message are you getting? Show us what code you have so far. We're not going to do your work for you, but if you have a specific problem we can try to point you in the right direction to get help.

                  R Offline
                  R Offline
                  rajulama
                  wrote on last edited by
                  #9

                  If OpenFileDialog1.ShowDialog(Me) = DialogResult.OK Then
                  Dim fi As New FileInfo(OpenFileDialog1.FileName)
                  Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Text;Data Source=" & fi.DirectoryName
                  Dim objConn As New OleDbConnection(sConnectionString)
                  Dim objDataSet As DataSet = New DataSet()
                  objConn.Open()
                  Dim objCmdSelect As New OleDbCommand("SELECT * FROM " & fi.Name, objConn)
                  Dim objAdapter1 As New OleDbDataAdapter
                  objAdapter1.SelectCommand = objCmdSelect
                  objAdapter1.Fill(objDataSet, "test")
                  DataGridView1.DataSource = objDataSet.Tables(0).DefaultView
                  objConn.Close()
                  End If

                  I have this and now to replace the data in existing database with that in datagridview I am using:

                  objAdapter1.Update(Me.dataset.filename)

                  But its not making any change in dataset table.rest is ok.

                  K 1 Reply Last reply
                  0
                  • R rajulama

                    If OpenFileDialog1.ShowDialog(Me) = DialogResult.OK Then
                    Dim fi As New FileInfo(OpenFileDialog1.FileName)
                    Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Text;Data Source=" & fi.DirectoryName
                    Dim objConn As New OleDbConnection(sConnectionString)
                    Dim objDataSet As DataSet = New DataSet()
                    objConn.Open()
                    Dim objCmdSelect As New OleDbCommand("SELECT * FROM " & fi.Name, objConn)
                    Dim objAdapter1 As New OleDbDataAdapter
                    objAdapter1.SelectCommand = objCmdSelect
                    objAdapter1.Fill(objDataSet, "test")
                    DataGridView1.DataSource = objDataSet.Tables(0).DefaultView
                    objConn.Close()
                    End If

                    I have this and now to replace the data in existing database with that in datagridview I am using:

                    objAdapter1.Update(Me.dataset.filename)

                    But its not making any change in dataset table.rest is ok.

                    K Offline
                    K Offline
                    Kschuler
                    wrote on last edited by
                    #10

                    Show us the code around your update statement. Is your command still setup when you issue the update? Shouldn't your update statement be something more like this: odjAdapter1.Update(Me.objDataSet.Tables("test")) ??

                    1 Reply Last reply
                    0
                    • R rajulama

                      Hello Dave Kreskowiak, please believe me its not a homework assignment. actually I am doing it as a part of the development. I have been trying : objAdapter1.Update(Me.Db1DataSet.Sheet1) but its not working. I just want your help on updating the database with this datgridview that's all. Rest I can do. Please help me!

                      Y Offline
                      Y Offline
                      Yusuf
                      wrote on last edited by
                      #11

                      rajulama wrote:

                      please believe me its not a homework assignment

                      Ok, I'll take your word

                      rajulama wrote:

                      actually I am doing it as a part of the development.

                      If I can not get my work done at my job, then I'll have to face the reality. Shouldn't you?

                      Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

                      1 Reply Last reply
                      0
                      • D Dave Kreskowiak

                        Jon_Boy wrote:

                        "Dave the almighty who rules next to Xerxes - could you find it in your gracious heart to feel pity upon my disgraced soul and help me with my problem? I am nothing without your assistance and bow before your presence."

                        OK, OK, I don't need to be wiping your lipstick off my ass! :-D

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                             2006, 2007, 2008

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        +5 for the wit, -5 for not wanting a little lipstick on the ass.

                        Check out the CodeProject forum Guidelines[^]

                        R 1 Reply Last reply
                        0
                        • L Lost User

                          +5 for the wit, -5 for not wanting a little lipstick on the ass.

                          Check out the CodeProject forum Guidelines[^]

                          R Offline
                          R Offline
                          rajulama
                          wrote on last edited by
                          #13

                          If OpenFileDialog1.ShowDialog(Me) = DialogResult.OK Then
                          Dim fi As New FileInfo(OpenFileDialog1.FileName)
                          Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Text;Data Source=" & fi.DirectoryName
                          Dim objConn As New OleDbConnection(sConnectionString)
                          Dim objDataSet As DataSet = New DataSet()
                          objConn.Open()
                          Dim objCmdSelect As New OleDbCommand("SELECT * FROM " & fi.Name, objConn)
                          Dim objAdapter1 As New OleDbDataAdapter
                          objAdapter1.SelectCommand = objCmdSelect
                          objAdapter1.Fill(objDataSet, "test")
                          DataGridView1.DataSource = objDataSet.Tables(0).DefaultView
                          objConn.Close()

                          After this I wrote:

                          objAdapter1.Update(Me.Db1DataSet.Sheet1("test"))

                          Because the dataset that I want to update is in by DB1DataSet.Sheet1. I dont want to update the datagridview itself. I want to update an existing database called DB1DataSet.Sheet1 from the datagridview. when I wrote above line its says following error:

                          Error 1 Overload resolution failed because no accessible 'Update' can be called with these arguments:
                          'Public Function Update(dataTable As System.Data.DataTable) As Integer': Value of type 'WindowsApplication1.db1DataSet.Sheet1Row' cannot be converted to 'System.Data.DataTable'.
                          'Public Function Update(dataRows() As System.Data.DataRow) As Integer': Value of type 'WindowsApplication1.db1DataSet.Sheet1Row' cannot be converted to '1-dimensional array of System.Data.DataRow'.
                          'Public Overrides Function Update(dataSet As System.Data.DataSet) As Integer': Value of type 'WindowsApplication1.db1DataSet.Sheet1Row' cannot be converted to 'System.Data.DataSet'.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups