Adding rows in Postgres

bombermwc

New member
Joined
Sep 22, 2005
Messages
1
Programming Experience
Beginner
I've been working on getting a row added to a pstgres DB using the ODBC connection in vb.net. I can add the data to the listbox that I'm working in, but I can't get it to actually update the database. Any ideas?

INFO:
table = location
locationid = PK
locationname = name of the location
adapater = dalocation
dataset = dslocation




Private
Sub btnAddLocation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddLocation.Click
Dim newLocation As DataRow = DsLocation.location.NewRow

Try

'grab count for number of elements and add one to remove "0" value

'then set the column value to that number

addLocationIdIndex = DsLocation.Tables("location").Rows.Count + 1

newLocation("locationid") = addLocationIdIndex

'grab the text for the location being added and set the column to that string

addLocationName = txtAddLocation.Text

newLocation("locationname") = addLocationName

'send new information to the dataset

DsLocation.location.Rows.Add(newLocation)

'send the new dataset to the dataadapter to update the database

daLocation.Update(DsLocation, "location")

'clear text box for next location

txtAddLocation.Text = ""

Catch ex As Exception

MessageBox.Show("Unable to add to the database.", "Database Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

End Sub

 
Back
Top