|
-
Jan 20th, 2013, 10:34 PM
#1
Thread Starter
Member
[RESOLVED] load multiple csv file to mysql via mysql client
Hi Expert,
I am new coders, I have a problem importing or updating mysql table, I dont know how to start this, Is this possible?, I have only little code but it is very bugy, what is the best language vb.net or c#, please help me
here is my buggy code:
Code:
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports MySql.Data.MySqlClient
Public Class Main
Private DS As DataSet
Private DA As MySqlDataAdapter
Private BS As BindingSource
Private Sub cmdbrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbrowse.Click
Dim fName As String = ""
'OpenFileDialog1.InitialDirectory = "c:\temp\"
OpenFileDialog1.Filter = "CSV files (*.csv)|*.CSV"
OpenFileDialog1.FilterIndex = 2
OpenFileDialog1.RestoreDirectory = True
If (OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
fName = OpenFileDialog1.FileName
End If
txtloc1.Text = fName
End Sub
Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
Dim conn As New MySqlConnection
conn.ConnectionString = "Server=server; User Id=root; Password=; Database=stock_data"
'Dim myConnection As New MySqlConnection(conn)
Dim cmd As String = "SELECT 8 FROM stock_data "
DA = New MySqlDataAdapter(cmd, conn)
' This line of code to generate update commands automatically.
' This update method of would not work without this line of code.
Dim MySQLCommandBuilder As New MySqlCommandBuilder(DA)
conn.Open()
DS = New DataSet()
DA.Fill(DS, "stock_data")
BS = New BindingSource
BS.DataSource = DS.Tables(0)
Dim BN As BindingNavigator = New BindingNavigator()
BN.BindingSource = BS
DataGridView1.DataSource = DS
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|