alsam
asked on
Update changes against db using axspreadsheet
Hi,
Im trying to provide end users to be able to manipuate with data using axspreadsheet.
I successfully loaded data from db into axspreadsheet but when I tried to update changes made by end user against db then nothing happened.
Can someone help me to find solution for the problem...
Code below....
Thanks in advance
Im trying to provide end users to be able to manipuate with data using axspreadsheet.
I successfully loaded data from db into axspreadsheet but when I tried to update changes made by end user against db then nothing happened.
Can someone help me to find solution for the problem...
Code below....
Thanks in advance
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
AxSpreadsheet1.Worksheets(1).Cells.Clear()
AxSpreadsheet1.Worksheets(1).Name = "MyWorksheet"
AxSpreadsheet1.Worksheets(1).StandardWidth = 25
Dim connect As New Data.SqlClient.SqlConnection(My.Settings.Connection)
Dim cmd As New Data.SqlClient.SqlCommand
Dim k As Integer
cmd.CommandText = "SELECT * FROM TreeViewItems"
cmd.Connection = connect
If connect.State = ConnectionState.Closed Then connect.Open()
da = New Data.SqlClient.SqlDataAdapter(cmd)
Dim commandBuilder As New Data.SqlClient.SqlCommandBuilder(da)
da.InsertCommand = commandBuilder.GetInsertCommand()
da.UpdateCommand = commandBuilder.GetUpdateCommand()
da.DeleteCommand = commandBuilder.GetDeleteCommand()
da.Fill(ds)
ProgressBar1.Value = 0
ProgressBar1.Maximum = ds.Tables(0).Rows.Count
k = 1
For ro As Integer = 0 To ds.Tables(0).Rows.Count - 1
k += 1
For cl As Integer = 0 To ds.Tables(0).Columns.Count - 1
AxSpreadsheet1.Worksheets(1).Cells(k, cl + 1) =
ds.Tables(0).Rows(ro).Item(cl).ToString
Next
ProgressBar1.Value += 1
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.da.Update(ds.Tables(0))
MsgBox("OK")
End Sub
End Class
Its because you are populating the speadsheet from the dataset but you are not writing it back to the dataset. The dataset is in same condition as it was when filled.
ASKER
Hi,
Thank you for your reply....
Could you please help me to reorganize my code in order to make this working....
This writing back to dataset .... I'm not sure how to make this correctly as you suggested...
Please help and thank you once more...
Thank you for your reply....
Could you please help me to reorganize my code in order to make this working....
This writing back to dataset .... I'm not sure how to make this correctly as you suggested...
Please help and thank you once more...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
Yes I can use DataGridView but for several reasons I have decided to use axspreadsheet. Why?
First, I'm trying to make application for controlling budgeting which is currently done in excel...
Somehow, I wanted to stay close to excel that users which make budget are very close to...
Secondly, axspreadsheet (as far as I'm concerned) gives nice possibility to make easy sum of data, data aligement, filter data etc which also can be done with DGV but in harder way for me to make working...
What is your opinion considering above...what would you prefer more in this case....
Maybe i'm wrong when I have decided to use axspreadsheet?!:)
Yes I can use DataGridView but for several reasons I have decided to use axspreadsheet. Why?
First, I'm trying to make application for controlling budgeting which is currently done in excel...
Somehow, I wanted to stay close to excel that users which make budget are very close to...
Secondly, axspreadsheet (as far as I'm concerned) gives nice possibility to make easy sum of data, data aligement, filter data etc which also can be done with DGV but in harder way for me to make working...
What is your opinion considering above...what would you prefer more in this case....
Maybe i'm wrong when I have decided to use axspreadsheet?!:)
I can not comment on your choice really. Depends on how resistent to change your users are. DataGridView would make your life easier though.
ASKER
Anyway,
thank you once more for your help...
thank you once more for your help...
Glad to help :-)