Click here to Skip to main content
15,891,033 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionUnencrypted Login Form Pin
edwcodeproject12-Apr-09 23:45
edwcodeproject12-Apr-09 23:45 
AnswerRe: Unencrypted Login Form Pin
Colin Angus Mackay13-Apr-09 0:02
Colin Angus Mackay13-Apr-09 0:02 
GeneralRe: Unencrypted Login Form Pin
EliottA13-Apr-09 2:08
EliottA13-Apr-09 2:08 
GeneralRe: Unencrypted Login Form Pin
Colin Angus Mackay13-Apr-09 2:13
Colin Angus Mackay13-Apr-09 2:13 
GeneralRe: Unencrypted Login Form Pin
EliottA13-Apr-09 2:24
EliottA13-Apr-09 2:24 
GeneralRe: Unencrypted Login Form Pin
Colin Angus Mackay13-Apr-09 2:28
Colin Angus Mackay13-Apr-09 2:28 
GeneralRe: Unencrypted Login Form Pin
EliottA13-Apr-09 2:29
EliottA13-Apr-09 2:29 
QuestionHow can I edit datagridview by importing csv file into it Pin
rajulama12-Apr-09 19:40
rajulama12-Apr-09 19:40 
Hi, I m trying to develop a small application where I have to read the data from csv file, display it in DGV and update the database so that I can execute a query related to the database. My code is as follows:

Public Class Form1
    Dim myDA As OleDbDataAdapter
    Dim myDataSet As DataSet

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=|DataDirectory|\db1.mdb")
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Sheet1", con)
        con.Open()
        myDA = New OleDbDataAdapter(cmd)
        Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA)
        myDataSet = New DataSet()
        myDA.Fill(myDataSet, "MyTable")
        DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView
        con.Close()
        con = Nothing
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Validate()
        Me.myDA.Update(Me.myDataSet.Tables("MyTable"))
        Me.myDataSet.AcceptChanges()
    End Sub

    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=|DataDirectory|\db1.mdb")
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Query3", con)
        con.Open()
        myDA = New OleDbDataAdapter(cmd)
        Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA)
        myDataSet = New DataSet()
        myDA.Fill(myDataSet, "MyTable")
        DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView
        con.Close()
        con = Nothing
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.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 Con As New OleDbConnection(sConnectionString)
            Dim myDataSet As DataSet = New DataSet()
            Dim cmd As OleDbCommand = New OleDbCommand
            Con.Open()
            myDA = New OleDbDataAdapter(cmd)
            Dim objCmdSelect As New OleDbCommand("SELECT * FROM " & fi.Name, Con)
            Dim objAdapter1 As New OleDbDataAdapter
            myDA.SelectCommand = objCmdSelect
            myDA.Fill(myDataSet, "MyTable")
            DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView
            Con.Close()
            Con = Nothing
        End If
    End Sub
   
End Class


Now my problem is that when I import csv into DGV and click button1, its not updating the database i.e its not executing my query3. I don't know what's wrong.

In fact what i want to do is just to import a csv file into an existing database and execute a query. I am not sure about the way in which I am doing it. Please suggest me.
AnswerRe: How can I edit datagridview by importing csv file into it Pin
Mycroft Holmes12-Apr-09 23:26
professionalMycroft Holmes12-Apr-09 23:26 
GeneralRe: How can I edit datagridview by importing csv file into it Pin
rajulama13-Apr-09 3:26
rajulama13-Apr-09 3:26 
GeneralRe: How can I edit datagridview by importing csv file into it Pin
Dave Kreskowiak13-Apr-09 3:47
mveDave Kreskowiak13-Apr-09 3:47 
GeneralRe: How can I edit datagridview by importing csv file into it Pin
rajulama13-Apr-09 4:06
rajulama13-Apr-09 4:06 
GeneralRe: How can I edit datagridview by importing csv file into it Pin
Dave Kreskowiak13-Apr-09 6:41
mveDave Kreskowiak13-Apr-09 6:41 
Questionproblem related to tab control Pin
nazimghori12-Apr-09 18:34
nazimghori12-Apr-09 18:34 
AnswerRe: problem related to tab control Pin
Dave Kreskowiak12-Apr-09 18:47
mveDave Kreskowiak12-Apr-09 18:47 
QuestionRe: problem related to tab control Pin
nazimghori12-Apr-09 19:58
nazimghori12-Apr-09 19:58 
AnswerRe: problem related to tab control Pin
Dave Kreskowiak13-Apr-09 3:46
mveDave Kreskowiak13-Apr-09 3:46 
AnswerRe: problem related to tab control Pin
Warp-1015-Apr-09 6:39
Warp-1015-Apr-09 6:39 
QuestionDynamically Load User Control WinForms - Please Help!! Pin
New2This212-Apr-09 17:26
New2This212-Apr-09 17:26 
AnswerRe: Dynamically Load User Control WinForms - Please Help!! Pin
Dave Kreskowiak12-Apr-09 18:45
mveDave Kreskowiak12-Apr-09 18:45 
GeneralRe: Dynamically Load User Control WinForms - Please Help!! Pin
New2This213-Apr-09 3:15
New2This213-Apr-09 3:15 
GeneralRe: Dynamically Load User Control WinForms - Please Help!! Pin
Dave Kreskowiak13-Apr-09 3:48
mveDave Kreskowiak13-Apr-09 3:48 
GeneralRe: Dynamically Load User Control WinForms - Please Help!! Pin
New2This213-Apr-09 4:55
New2This213-Apr-09 4:55 
Questionhow to upload excel file data to access if excel file have header with special character Pin
paine113511-Apr-09 23:48
paine113511-Apr-09 23:48 
AnswerRe: how to upload excel file data to access if excel file have header with special character Pin
Eddy Vluggen12-Apr-09 23:55
professionalEddy Vluggen12-Apr-09 23:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.