I made a query for inserting a value from text box to MS ACCESS db

sql = "INSERT INTO Equipment (port_number,display_name,equipment,tonnage,user_privilage) VALUES (" & CLng(txtPort.Text) & ", '" & CStr(txtDisplay.Text) & "', '" & CStr(txtCA.Text) & "', " & CLng(txtTonnage.Text) & ", '" & CStr(cmbUser.Text) & "')"

Actually I meant for inserting the data entered in the text box, but now saving is the code itself i,e; in port_number column 'CIng(txtPort.Text) ' will be saved
I dont know what's the problem
Please help me

Recommended Answers

All 3 Replies

I don't see anything specifically wrong with your SQL statement, although I would caution against going directly to the database with unfiltered string content. Explore parameterized queries or, at minimum, escape single quotes in your strings (by replacing a single quote with 2 single quotes).

What about your connection and command objects? Are they throwing specific errors?

When I type some data on text box and click the button 'Save' in db only storing the word in the SQL command like

' & txtPort.Text & '

like that. There is no error messages . What you think. Can you help me

When I type some data on text box and click the button 'Save' in db only storing the word in the SQL command like like that. There is no error messages . What you think. Can you help me

Is there any error message?

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.