When to trying to display data to datagrid view using query i got an error
"a column named date already belongs to this datatable in net 2008"
Dim dt As New DataTable
Try
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
Dim cmd As New SqlClient.SqlCommand
With cmd
.CommandText = "SELECT [Date],[Totalamount] FROM [Mobilization] where [Contract_Name]='" & ComboBox1.Text & "' AND [Client_Name]='" & ComboBox2.Text & "'"
.CommandType = CommandType.Text
.Connection = myConnection
End With
dt.Load(cmd.ExecuteReader)
dt.Columns.Add(New DataColumn("Date", System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("Total Amount", System.Type.GetType("System.Double")))
DataGridView1.DataSource = dt
myConnection.Close()
Catch err As Exception
MsgBox(err.Message, MsgBoxStyle.Exclamation)
End Try
I couldn't find what is the error