Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27196

VS 2010 Im having trouble with DGV

$
0
0
Hello everyone im new to this forum :D
I hope you can help me for starters im looking to save and update files from my datagridview
So.. I'll post some code
Imports System.Data.OleDb

Public Class Form18

Const cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=I:\PAP\Access Solução 1.accdb"
Dim nome As String
Dim a As Date
Dim con As New OleDbConnection(cs)
Dim myDataSet As DataSet = New DataSet()
Dim DA As OleDbDataAdapter

Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
Me.Hide()
Form4.Show()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

If ComboBox1.Text = "Janeiro" Then
a = "10-01-2000"
ElseIf ComboBox1.Text = "Fevereiro" Then
a = "10-02-2000"
ElseIf ComboBox1.Text = "Março" Then
a = "10-03-2000"
ElseIf ComboBox1.Text = "Abril" Then
a = "10-04-2000"
ElseIf ComboBox1.Text = "Maio" Then
a = "10-05-2000"
ElseIf ComboBox1.Text = "Junho" Then
a = "10-06-2000"
ElseIf ComboBox1.Text = "Julho" Then
a = "10-07-2000"
ElseIf ComboBox1.Text = "Agosto" Then
a = "10-08-2000"
ElseIf ComboBox1.Text = "Setembro" Then
a = "10-09-2000"
ElseIf ComboBox1.Text = "Outubro" Then
a = "10-10-2000"
ElseIf ComboBox1.Text = "Novembro" Then
a = "10-11-2000"
ElseIf ComboBox1.Text = "Dezembro" Then
a = "10-12-2000"
End If

Dim query As String = "Select Nome,Taxa,Valor,Data from view1 where Month(Data) = Month('" & a & "') and Nome ='" & ComboBox2.Text & "'"
Dim cmd As New OleDbCommand(query, con)
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
con.Open()
myDA.Fill(myDataSet, "Data")
View1DataGridView.DataSource = myDataSet.Tables("Data").DefaultView
con.Close()

Dim sumTotal As String = myDataSet.Tables(0).Compute("SUM(Valor)", String.Empty).ToString
Label3.Text = "Valor total do IVA deste mês: " & sumTotal
End Sub
End Class



Sorry some of the stuff is in portuguese but I think its no big deal, now the result that is showed in the DGV I want to give to the user the possibility to update some ex : if valor(value) = 20 and user wants it 19 I want it to change and save in database.
And I want to let them delete it if they would like to now only the value but the row.
If you guys need any extra information just ask.
Please help :3

Viewing all articles
Browse latest Browse all 27196

Trending Articles