I am almost finished with my code but never inserted data into the database before. So far my SQL statement works fine but the final execution of the code I don't know how to do.
The new record doesn't show up in my database so I think I am missing a few lines at the end that makes the new record execute.
Protected Sub Insert_Click(sender As Object, e As EventArgs) Handles Insert.Click
Dim v_Date = DateText.Text
Dim v_Username = UserText.Text
Dim v_Phone = PhoneText.Text
Dim v_Email = EmailText.Text
Dim v_Category = CategoryList.Text
Dim v_Short = ShortText.Text
Dim v_Long = longText.Value
Dim conn As OleDbConnection = New OleDbConnection("Provider=""*********"";user id=" & strUserID & ";data source=" & strDatabase & ";password=" & strPssWd)
Dim ClassifiedStr As OleDbCommand = New OleDbCommand("INSERT INTO TABLENAME (Date, Username, Phonenbr, Email, Category, Description, Fulldescription) values('" & v_Date & "',lower('" & v_Username & "'),'" & v_Phone & "','" & v_Email & "','" & v_Category & "','" & v_Short & "','" & v_Long & "'", conn)
'ClassifiedStr.CommandType = CommandType.StoredProcedure
Dim OracleDataAdapterAds As OleDbDataAdapter = New OleDbDataAdapter
OracleDataAdapterAds.SelectCommand = ClassifiedStr
Dim DsAds As DataSet = New DataSet
DsAds.Clear()
'OracleDataAdapterAds.Fill(DsAds, "TABLENAME")
conn.Open()
'ClassifiedStr.ExecuteNonQuery()
End Sub
UPDATE
ERROR
Dim v_Date = DateText.Text
Dim v_Username = UserText.Text
Dim v_Phone = PhoneText.Text
Dim v_Email = EmailText.Text
Dim v_Category = CategoryList.Text
Dim v_Short = ShortText.Text
Dim v_Long = longText.Value
Dim conn As OleDbConnection = New OleDbConnection("Provider=""********"";user id=" & strUserID & ";data source=" & strDatabase & ";password=" & strPssWd)
conn.Open()
Dim ClassifiedStr As OleDbCommand = New OleDbCommand("INSERT INTO TABLENAME (Date, Username, Phonenbr, Email, Category, Description, Fulldescription) values(@v_Date, lower(@v_Username), @v_Phone, @v_Email, @v_Category, @v_Short, @v_Long)", conn)
ClassifiedStr.Parameters.Add("@v_Date", OleDbType.Date).Value = v_Date
ClassifiedStr.Parameters.Add("@v_Username", OleDbType.VarChar).Value = v_Username
ClassifiedStr.Parameters.Add("@v_Phone", OleDbType.VarChar).Value = v_Phone
ClassifiedStr.Parameters.Add("@v_Email", OleDbType.VarChar).Value = v_Email
ClassifiedStr.Parameters.Add("@v_Category", OleDbType.VarChar).Value = v_Category
ClassifiedStr.Parameters.Add("@v_Short", OleDbType.VarChar).Value = v_Short
ClassifiedStr.Parameters.Add("@v_Long", OleDbType.VarChar).Value = v_Long
ClassifiedStr.ExecuteNonQuery()
conn.Close()
For some reason INSERT SQL was giving me constant issues so I decided to go for a stored procedure instead.
With my stored procedure inside Oracle, the following is my VB.net code: