Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
con.Execute "INSERT INTO BOOK (BookID, BookName, Author, MemberID) VALUES (" & txtBookID & ", '" & txtBookN & "','" & txtAuthor & "', " & txtMID & ")"



I am creating Library Management System, from that I wanna inset data into datagrid, but getting error on the code mentioned above.
Can some one help me to this?

What I have tried:

I want to show that data in gridview, but can't.
Posted
Updated 1-May-18 18:47pm

1 solution

VB
con.Execute "INSERT INTO BOOK (BookID, BookName, Author, MemberID) VALUES (" & txtBookID & ", '" & txtBookN & "','" & txtAuthor & "', " & txtMID & ")"

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900