I have a system named library system and all works properly but not in borrowing i can search the books i want to borrow but when i input my member_ID i encountered runtime error which says " No value given for one or more required parameters" but i have filled all the blanks spellings are all correct the code is this :

Function save()
    query_mem_id = "Select * from Members where Mem_Id like '" & txtMem_id.Text & "' "
    rs2.Open query_mem_id, conn

can you please debugg it for me thank you :D have a nice day

Edited 1 Year Ago by Christian_4

Attachments chuva.jpg 234.31 KB

help pls asap

Edited 1 Year Ago by Christian_4: i forgot the picture

Attachments chuva.jpg 234.31 KB

Hi

can you please debugg it for me thank you :D have a nice day

We won't be able to debug it for you as we don't have your code or the database.

However, looking at the field name Mem_ID would suggest that this is a numeric field, is that the case? If it is, then do not surround your txtMem_id.Text in quotes, rather it should be query_mem_id = "Select * from Members where Mem_Id = " & txtMem_id.Text

Also, you are currently using a LIKE operator which again, if this is a numeric field will not work. If it is a Text field then you need to supply a wildcard on one or both sides like: query_mem_id = "Select * from Members where Mem_Id like '*" & txtMem_id.Text & "*' ". The asterix is the wildcard assuming this is an Access database. If it is SQL Server then use % instead.

Finally, the best way to debug this is to print out your query_mem_id value and run it directly in your database so that you can fix it up there and modify in your code afterwards.

HTH

Sir ty for your fast reply sir but the runtime error is still here all parts of my system work but the borrowing type doesnt end well i'm just beginner in using vb 6 sir and i hope this images can help me to solve my problem ty for helping sir

Edited 1 Year Ago by Christian_4: asdasd

Attachments 1.jpg 89.33 KB 2.jpg 255.3 KB 1.jpg 89.33 KB

Hi

In the image, the field is called "Mem_Id1" but you have "Mem_Id" in your query.

Here is what I recommend that you do which is a technique that I used when first starting with database programming:

  • Goto your Access database and create a new query
  • Add the Members table to the query and add the fields that you want to output
  • Add a criteria to the Mem_Id1 field of "cvsu"
  • Run the query and ensure that you are only getting data back for that Mem_Id1 value ("cvsu")
  • Now switch to the SQL view of the query and you will see the actual SELECT statement.
  • Copy this and put it into your code so that it will be something like:

    query_mem_id = "SELECT Mem_Id1, Mem_Name, Mem_Address, Mem_Contact, Mem_Role WHERE Mem_Id1 = 'cvsu';"

  • Now you need to modify the above to replace the hard coded 'cvsu' with your value, so that it becomes:

    query_mem_id = "SELECT Mem_Id1, Mem_Name, Mem_Address, Mem_Contact, Mem_Role WHERE Mem_Id1 = '" & txtMem_id.Text & "'"

Give this a go and see where that takes you.

Edited 1 Year Ago by djjeavons

i tried it sir and i have error and it says Syntax Error (missing operator) in query expression 'Mem_Role WHERE Mem_id1 ='Cvsu",

Hi

You haven't included the FROM statement. It should be "SELECT Mem_Id1, Mem_Name, Mem_Address, Mem_Contact, Mem_Role FROM Members WHERE Mem_Id1 = '" & txtMem_id.Text & "'"

sir now in database it says invalid sql statement; expected 'DELETE', 'INSERT','PROCEDURE' , 'SELECT' , or 'UPDATE' ty sir

Sorry, I don't understand.

Is the first query working now or is this error statement occuring as a result of the last query I pointed out?

my bad i copied even the quotations now sir after i have finished the database the query became blank is it what will happen?

No, it isn't correct yet. You have still forgotten to put the FROM keyword in.

The syntax of a SELECT statement is always:

SELECT (something) FROM (tablename)

You can then optionally include a WHERE criteria.

So your statement needs to include the FROM Members text before the WHERE Mem_Id1 statement.

"SELECT Mem_Id1, Mem_Name, Mem_Address, Mem_Contact, Mem_Role FROM Members WHERE Mem_Id1 = '" & txtMem_id.Text & "'"

Great, glad to help.

Please remember that tip I pointed out earlier, it makes writing queries a lot easier when you are fairly new to them and helps you to understand what is happening.

yes sir thank you even though i have no idea in vb 6 but with your instruction i feel like i know what i am doing ty sir!!! godbless!! it really helped me alot

Sir i have a last question sorry if i will just post in this thread how can you middle all of the form because my form is like teleporting somewhere in the screen

Now that the thread is marked as solved (and solution points appropriately allocated) I'd like to make a suggestion for formatting your queries that may help in keeping the code clearer. Instead of

qry = "SELECT Mem_Id1, Mem_Name, Mem_Address, Mem_Contact, Mem_Role FROM Members WHERE Mem_Id1 = '" & txtMem_id.Text & "'"

You might write it as

qry = "SELECT Mem_Id1, Mem_Name, Mem_Address, Mem_Contact, Mem_Role " _
    & "  FROM Members " _
    & " WHERE Mem_Id1 = '" & txtMem_id.Text & "'"

This becomes even more useful for longer queries. Also, I should point out that it is better to use parameterized queries. In that case the query would look like:

qry = "SELECT Mem_Id1, Mem_Name, Mem_Address, Mem_Contact, Mem_Role " _
    & "  FROM Members " _
    & " WHERE Mem_Id1 = ?"

Note that you don't have to worry about adding single quotes for strings. Delimiters are added for you when you use the Parameters.AddWithValue method to add the parameter values.

Edited 1 Year Ago by Reverend Jim

This question has already been answered. Start a new discussion instead.