Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\SmS Application\New.mdb")
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Dim DataSet1 As New DataSet
Dim cmdOLEDB As New OleDbCommand
Dim cmdInsert As New OleDbCommand
Dim cmdUpdate As New OleDbCommand
Dim cmdDelete As New OleDbCommand
Dim delete As New OleDb.OleDbCommand("delete INTO Table2 (PhoneNumber,Message,Dates) VALUES (@PhoneNumber,@Message, now())", con)
Dim adapter As New OleDb.OleDbDataAdapter("SELECT PhoneNumber, Message FROM Table2", con)
con.Open()
cmdDelete.CommandType = CommandType.Text
cmdDelete.Connection = con
If (MessageBox.Show("Are u sure want to delete ehere id = " & TextBox1.Text, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) = Windows.Forms.DialogResult.Yes Then
cmdDelete.CommandText = "DELETE FROM Table2 WHERE ID = " & TextBox1.Text
cmdDelete.ExecuteNonQuery()
MessageBox.Show(" Records Deleted!! ")
Else
End If
Exit Sub
cmdDelete.Dispose()
adapter.Update(DataSet1, "table2")
con.Close()
End Sub
how to update database @ runtime
Page 1 of 114 Replies - 1747 Views - Last Post: 16 April 2011 - 08:49 AM
#1
how to update database @ runtime
Posted 08 April 2011 - 02:05 AM
Replies To: how to update database @ runtime
#2
Re: how to update database @ runtime
Posted 08 April 2011 - 07:03 AM
#3
Re: how to update database @ runtime
Posted 08 April 2011 - 10:28 PM
modi123_1, on 08 April 2011 - 07:33 PM, said:
I have written it
adapter.Update(DataSet1, "table2")my problem is when i delete my data it will delete it and my data is updated but to see that updated data i hav to reopen the form!!!!so i want to do like this when i delete data from my datatable i can see that updated table in form without reopening the form Hope u understand
#4
Re: how to update database @ runtime
Posted 09 April 2011 - 09:16 AM
I am not sure what you are getting at, but how about after you 'update' you do a load from the database again? Is that showing your data then?
#5
Re: how to update database @ runtime
Posted 11 April 2011 - 01:29 AM
#6
Re: how to update database @ runtime
Posted 11 April 2011 - 06:47 AM
Here's some information.
http://msdn.microsof...=sql.80%29.aspx
#7
Re: how to update database @ runtime
Posted 11 April 2011 - 10:13 PM
modi123_1, on 11 April 2011 - 07:17 PM, said:
Here's some information.
http://msdn.microsof...=sql.80%29.aspx
Thank you !!!!!!!!!! i hav another problem i want 2 select data from data gridview and want retrive that data into another form in to the textbox...is it possible ???? i 'm doing like this for that
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myConnection As OleDbConnection = New OleDbConnection
Dim str_oledb_account_select As String = "SELECT * FROM Table3"
Dim comAccountSelect As OleDbCommand 'command for Account select
Dim myAccountAdapter As OleDbDataAdapter
Dim myAccountDataset As DataSet
Dim textbox2 As TextBox
Dim i, j As Integer
Dim vbn As Boolean
vbn = True
myConnection.Open()
'Instantiate the commands
comAccountSelect = New OleDbCommand(str_oledb_account_select, myConnection)
'Instantiate data adapter
myAccountAdapter = New OleDbDataAdapter(str_oledb_account_select, myConnection)
'Set data adapter command properties
myAccountAdapter.SelectCommand = comAccountSelect
'Instantiate the datasets
myAccountDataset = New DataSet()
'Populate the dataset
myAccountAdapter.Fill(myAccountDataset, "Table3")
j = myAccountDataset.Tables("Table3").Rows.Count()
For i = 0 To (j - 1)
TextBox2.Text = myAccountDataset.Tables("Table3").Rows(i)(0)
Next
End Sub
Please help regarding this !!!!!!!
This post has been edited by hardygandhi: 11 April 2011 - 10:15 PM
#8
Re: how to update database @ runtime
Posted 12 April 2011 - 07:11 AM
i want 2 select data from data gridview
That's pretty straight forward. There are events for the grid that will help you with that.
and want retrive that data into another form in to the textbox...is it possible ????
You want to take a row of data from the grid and send it to a second form that has a text box? Yes that is possible.
i 'm doing like this for that
I see you loading up the data, and you looping through a table overwriting a textbox's comment. What I don't see is the second form being declared. I also don't understand why you are looping through a dataset and over writing the contents of a text box. That doesn't make sense.
#9
Re: how to update database @ runtime
Posted 13 April 2011 - 10:30 PM
#10
Re: how to update database @ runtime
Posted 14 April 2011 - 08:09 AM
#11
#12
Re: how to update database @ runtime
Posted 15 April 2011 - 06:14 AM
#13
Re: how to update database @ runtime
Posted 15 April 2011 - 07:29 AM
User selects row.
user hits button, double clicks, what ever - triggers an event that starts sending data to another form.
Grab the grid's current selected row. Make sure to have multiple select off, or determine how to deal with multiple selected rows.
Grab what ever cell of data from that row.
On form2 have a public string property that links to the textbox's text property.
Create a new instance of form2.
The cell of data mentioned above - assign that to this form2 instance's text property you made.
Show form2
#14
Re: how to update database @ runtime
Posted 15 April 2011 - 10:30 PM
modi123_1, on 15 April 2011 - 07:59 PM, said:
User selects row.
user hits button, double clicks, what ever - triggers an event that starts sending data to another form.
Grab the grid's current selected row. Make sure to have multiple select off, or determine how to deal with multiple selected rows.
Grab what ever cell of data from that row.
On form2 have a public string property that links to the textbox's text property.
Create a new instance of form2.
The cell of data mentioned above - assign that to this form2 instance's text property you made.
Show form2
Atleast u shud say dat d code i show u for the retrivig data is near about my work or not??
#15
Re: how to update database @ runtime
Posted 16 April 2011 - 08:49 AM
|
|

New Topic/Question
Reply



MultiQuote






|