hi
i'm using VS 2008 to design a windows application. I'm using ms access as my database but i'm having trouble saving form data into my database. I run this code and get no errors but no data is saved in the database table
Imports System.Data.OleDb
Imports System
Imports System.Data
Public Class HousingFrm
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim sql As String
Try
sql = "INSERT INTO Housing(type, description, location) VALUES('" & typeTextBox.Text & "', '" & housingDescription.Text & "', '" & locationTextBox.Text & "')"
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TMSDB.mdb;User ID=Admin;Password=")
conn.Open()
comm = New OleDbCommand(sql, conn)
comm.ExecuteNonQuery()
conn.Close()
comm.Dispose()
conn.Dispose()
MsgBox("Housing Information has been successfully saved. Thank you")
Catch ex As Exception
End Try
End Sub
i'm using VS 2008 to design a windows application. I'm using ms access as my database but i'm having trouble saving form data into my database. I run this code and get no errors but no data is saved in the database table
Imports System.Data.OleDb
Imports System
Imports System.Data
Public Class HousingFrm
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim sql As String
Try
sql = "INSERT INTO Housing(type, description, location) VALUES('" & typeTextBox.Text & "', '" & housingDescription.Text & "', '" & locationTextBox.Text & "')"
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TMSDB.mdb;User ID=Admin;Password=")
conn.Open()
comm = New OleDbCommand(sql, conn)
comm.ExecuteNonQuery()
conn.Close()
comm.Dispose()
conn.Dispose()
MsgBox("Housing Information has been successfully saved. Thank you")
Catch ex As Exception
End Try
End Sub