|
-
Nov 19th, 2002, 07:03 AM
#1
Thread Starter
Lively Member
Database Note Updated !
I posted this message in API by misstake.....
Hi All,
Finaly I found a way to get my data & I hope it's correct..
1. Created the DataAdapter
2. Created the DataSet
3. Filled the DataAdapter with the my table information.
Now I need to assign my info which in the table to appear in my form textbox, so to do that I did the following:
I created a DataRow object:
For Each myDR In myDS.Tables("Bank").Rows
Next
Then assign my form textbox to the fiels:
Me.txtBankName_e.Text = Trim(myDR("bankname_e"))
But stuck in 2 things:
1. Could not assign the myDS to my combo box ( Me.cbSelect.DataSource = myDS)
2. Could not update the dataset with the modified data :
myDR.BeginEdit()
myDR("bankname_e") = Me.txtBankName_e.Text
myDR.EndEdit()
myDR.AcceptChanges()
myDA.Update(myDS, "bank")
Any suggestions please.
ADSC
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
-
Nov 19th, 2002, 09:06 PM
#2
Sleep mode
this will solve your second question
OK. umm
what a nightmare is that .look what I've figured out :
VB Code:
'//declare the following in the general declaration of the form//
' The DataSet.
Private MYDATASET As New DataSet(" DATA_SET_NAME")
' Data adapter for the AN_BANK_1 table.
Dim MYDA1 As New SqlDataAdapter( _
"SELECT * FROM AN_BANK_1", MYCONN.OCONNECTION)
' Data adapter for the AN_BANK_2 table.
Dim MYDA2 As New SqlDataAdapter( _
"SELECT * FROM AN_BANK_2", MYCONN.OCONNECTION)
'// then use this call this SUB
Private Sub UPDATE_Changes()
'this sub will update modified and inserted records.
Dim MODIFIED_DATA As DataSet = MYDATASET.GetChanges( _
DataRowState.Modified Or DataRowState.Added)
If Not (MODIFIED_DATA Is Nothing) Then
'for modified records
MYDA1.Update(MODIFIED_DATA)
'for inserted records
MYDA2.Update(MODIFIED_DATA, "TestScores")
End If
' this sub should works with modified and inserted records
I haven't tried this but seems to work
Pirate
-
Nov 20th, 2002, 03:17 PM
#3
Thread Starter
Lively Member
Oh grate it seems you changed your mind,
Still it’s not working, but I think I found another way around….
‘ Declaration part:
Dim myDS As New DataSet()
Dim myDR As DataRow
Dim mySql = "SELECT * FROM AN_Bank"
Dim myDA As New SqlDataAdapter(mySql, myConn.oConnection)
Dim myCB As New SqlCommandBuilder(myDA)
myDA.UpdateCommand = myCB.GetUpdateCommand
myDA.Fill(myDS, "Bank")
' Fill the DataRow
myDR = myDS.Tables("Bank").Rows(0)
‘ Update part:
myDR("bankname_e") = "English Bank Name"
If myDA.Update(myDS, "Bank") = 1 Then
myDS.AcceptChanges()
Else
myDS.RejectChanges()
End If
Thanks for your help
ADSC
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
-
Nov 20th, 2002, 03:23 PM
#4
Sleep mode
then nice job . ok what about using GetChanges and Update methods , Can they do the job ???
-
Nov 20th, 2002, 03:34 PM
#5
Thread Starter
Lively Member
Ummm, I need to try it and I'll let you know .....
* * * Please Wait * * *
**** Cocking The Code ****
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
-
Nov 20th, 2002, 03:44 PM
#6
-
Nov 20th, 2002, 04:13 PM
#7
Thread Starter
Lively Member
First error you need to add the table name :
MYDA1.Update(MODIFIED_DATA, "TabelName")
The second error I got :
(Additional information: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.)
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|