danielagaba 0 Junior Poster in Training

hi,

i'm using VS2008 and used the database wizard to make sure my database table and dataset datatable match. I used following code to transfer data from my windows form to my dataset then database. I keep getting an error saying "Invalid Object name 'Housing'" and I cant find the error.

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

try

Dim housetype As String = Me.typeTextBox.Text
Dim desc As String = Me.descriptionTextBox.Text
Dim loc As String = Me.locationTextBox.Text

Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFileName=C:\Users\Daniel\Documents\TMSDB.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True")

Dim ds As New DataSet
conn.Open();

Dim dap As New SqlDataAdapter("Select * from Housing", conn)
dap.Fill(ds, "Housing")

Dim dr As DataRow = ds.Tables("Housing").NewRow()
dr(0) = ""
dr(1) = houseType
dr(2) = desc
dr(3) = loc

ds.Tables("Housing").Rows.Add(dr)
dap.Update(ds, "Housing")

MessageBox.Show("Information Entered Successfully")

Catch ex As Exception

MessageBox.Show("Error entering information")

End try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.