Click to See Complete Forum and Search --> : db not reading the information


xxsoulxx
January 28th, 2006, 02:14 PM
hi there , i am having problems getting my data to the db .. there are no errors displaying .. its just that data wont go in ...


Dim a As String

Dim b As String

a = TextBox1.Text

Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\temp\db1.mdb")

Dim strSQL As String = "INSERT INTO Table1 (yo,yoyo) VALUES (a,a) where user = '" + TextBox2.Text + "'"

'Dim strSQL As String = "INSERT INTO Settins (PhotoUpload) VALUES (@img) WHERE UserID = '" + rId + "'"

Dim cmd As New OleDbCommand(strSQL, cnn)

Try

cnn.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

'lb_Msg.Text = ex.Message

Finally

If Not cmd Is Nothing Then

cmd.Dispose()

End If

If Not cnn Is Nothing Then

cnn.Close()

cnn.Dispose()

End If

End Try

End Sub

mmetzger
January 28th, 2006, 06:32 PM
You have your exception message commented out - how are you determining there's not a problem?

xxsoulxx
January 29th, 2006, 12:25 AM
they told me Missing semicolon (;) at end of SQL statement.

but i cant seem to figure out where ?

mmetzger
January 29th, 2006, 09:29 AM
Try:


Dim strSQL As String = "INSERT INTO Table1 (yo,yoyo) VALUES (a,a) where user = '" + TextBox2.Text + "';"

xxsoulxx
January 29th, 2006, 10:01 AM
hi thx .. it solve the problem ...

now i am trying update but seems to hit a different kind of problem ..
Server was unable to process request. --> No value given for one or more required parameters.


Dim a As String
Dim b As String

Dim strSNameFont As String
Dim strSNameSize As String
Dim strSNameColor As String

Dim strNameBold As String
Dim strNameItalic As String
Dim strnameunderline As String

strSNameFont = ddlSNameFont.SelectedValue
strSNameSize = ddlSNameSize.SelectedValue
strSNameColor = ddlSNameColor.SelectedValue
strNameBold = cbNameBold.Checked
strNameItalic = cbNameItalic.Checked
Dim i As Integer = 1

strnameunderline = "nil"

a = TextBox1.Text
Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\TDB.mdb")


Dim strSQL As String = "UPDATE Settings SET NameFont = '" + strSNameFont + "', FontSize = '" + strSNameSize + _
"', FontColor = '" + strSNameColor + _
"', FBold = '" + strNameBold + _
"', FItalic = '" + strNameItalic + _
"' WHERE UserID='" + TextBox2.Text + "'"


Dim cmd As New OleDbCommand(strSQL, cnn)
cnn.Open()
cmd.ExecuteNonQuery() <----- in red

cnn.Close()

End Sub

mmetzger
January 29th, 2006, 08:11 PM
There's something wrong in your query based on the database setup. Try the exact query in the database tools and see what errors occur.

Also, you should really use parameterized queries to prevent sql injection attacks. You're trusting the fact that the data the user enters will be exactly what you expect.

xxsoulxx
January 30th, 2006, 08:48 AM
hehe problem solved ...