I want to create a program that upload CSV
file in DataGridView
then after displaying the csv
file I want all the data in datagridview to save in my database... The problem is the date format can't display as yyyy/MM/dd
to database.
Error of this code
No default member found for type 'Date'.
Code
Dim sched_date As String
Dim agent_name, campaign_name, team_name, schedule As Object
For i As Integer = 0 To DataGridView1.Rows.Count - 1
agent_name = DataGridView1.Rows(i).Cells(0).Value()
campaign_name = DataGridView1.Rows(i).Cells(1).Value()
team_name = DataGridView1.Rows(i).Cells(2).Value()
sched_date = DataGridView1.Rows(i).Cells(3).Value("yyyy/MM/dd")
schedule = DataGridView1.Rows(i).Cells(4).Value()
query = " Select * from tbl_sched WHERE agent_name = '" + agent_name + "'"
mysql_connect(True)
cmd = New MySqlCommand(query, SQLConnection)
reader = cmd.ExecuteReader()
If reader.Read() Then
mysql_connect(False)
query = "update tbl_sched set campaign_name='" + campaign_name + "',team_name='" + team_name + "',sched_date='" + sched_date + "',schedule='" + schedule + "' WHERE agent_name ='" + agent_name + "'"
mysql_connect(True)
cmd = New MySqlCommand(query, SQLConnection)
cmd.Connection = SQLConnection
cmd.CommandText = query
cmd.ExecuteNonQuery()
Else
mysql_connect(False)
query = "insert into tbl_sched (agent_name,campaign_name,team_name,sched_date,schedule) values ('" + agent_name + "','" + campaign_name + "','" + team_name + "','" + sched_date + "','" + schedule + "')"
mysql_connect(True)
cmd = New MySqlCommand(query, SQLConnection)
cmd.Connection = SQLConnection
cmd.CommandText = query
cmd.ExecuteNonQuery()
End If
Next
MsgBox("Successfully upload CSV file to Database")