This is rediculous: Still not able to Add a row!!!???

A

Aaron Ackerman

I have reduced this thing down to the bare essentials and I still cannot add
a row. I have taken the suggestions and nothing.
I am pulling from the DB just find I just cannot add (so my connection is
good). I step thhrough this thing and I am definatly seeing a new row
getting added to the dataset so something must be wrong with the way I am
updateing the dataadapter...HELP!!! (THESE ARE ALL VISUAL CONTROLS)

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
'Brand NEW request Fill the dataset and bind the data to the
grid
vdaPasswords.Fill(dsPasswords1)
Session("dsPasswords") = dsPasswords1
BindGrid()
End If
End Sub


' Bind the database to the table
Private Sub BindGrid()
dsPasswords1 = Session("dsPasswords")
DataGrid1.DataSource = dsPasswords1
DataGrid1.DataBind()
End Sub

' The "Add" button on this form is separate from the grid
Private Sub Add()
Dim dr As dsPasswords.PasswordsRow
dsPasswords1 = Session("dsPasswords")
dr = dsPasswords1.Tables("Passwords").NewRow()
dr("NUMBER") = 180
dr("USERNAME") = "SDASD"
dsPasswords1.Tables("Passwords").Rows.InsertAt(dr, 0)
DataGrid1.EditItemIndex = 0


dsPasswords1.AcceptChanges()
vdaPasswords.Update(dsPasswords1)


End Sub
 
D

Daniel Bass

you're not binding the new data to the datagrid after you've changed your
table...

try...

Private Sub Add()
Dim dr As dsPasswords.PasswordsRow
dsPasswords1 = Session("dsPasswords")
dr = dsPasswords1.Tables("Passwords").NewRow()
dr("NUMBER") = 180
dr("USERNAME") = "SDASD"
dsPasswords1.Tables("Passwords").Rows.InsertAt(dr, 0)
DataGrid1.EditItemIndex = 0

dsPasswords1.AcceptChanges()
vdaPasswords.Update(dsPasswords1)

DataGrid1.DataSource = dsPasswords1
DataGrid1.DataBind()
Session( "dsPasswords" ) = dsPasswords1

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top