7 Replies - 1341 Views - Last Post: 08 August 2012 - 05:54 PM Rate Topic: -----

#1 yobe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-August 12

no value given for one or more required parameters vb6

Posted 06 August 2012 - 06:47 PM

Please someone help me with this. I can't save the data into database. Error :"no value given for one or more required parameters" keep coming. Below is the screenshot. Thank you in advance.

Attached image(s)

  • Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: no value given for one or more required parameters vb6

#2 yobe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-August 12

Re: no value given for one or more required parameters vb6

Posted 06 August 2012 - 07:32 PM

p/s this is the real sample code. Please what is wrong with this coding. :(

con.Execute ("insert into Questions values('" + combosubject.Text + "'," + txtsbcode.Text + _
                ",'" + Text1.Text + "','" + txtq.Text + _
                "','" + opt1.Text + "','" + opt2.Text + _
                "','" + opt3.Text + "','" + opt4.Text + "','" + real.Text + "')")

Was This Post Helpful? 0
  • +
  • -

#3 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 271
  • View blog
  • Posts: 1,632
  • Joined: 26-March 09

Re: no value given for one or more required parameters vb6

Posted 06 August 2012 - 11:51 PM

Are you specifying all columns in your query?

If not you need to change your syntax to specify the columns.

INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)]
VALUES (value1, value2, value3,...valueN);

Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is online

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 541
  • View blog
  • Posts: 2,887
  • Joined: 19-May 09

Re: no value given for one or more required parameters vb6

Posted 07 August 2012 - 12:32 PM

To expand upon what maj is saying: if you don't specify exactly which columns you want to insert into, the insert statement assumes that you are inserting into all the fields in the table, and expects a value for each field in the table. You're probably not providing the same number of values as there are fields in the table.
Was This Post Helpful? 0
  • +
  • -

#5 yobe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-August 12

Re: no value given for one or more required parameters vb6

Posted 07 August 2012 - 06:38 PM

I try rewrite the code into this :
con.Execute ("insert into Questions (Subjectname, Subjectcode, ExamID, Qno, Qst, Ch1, Ch2, Ch3, Ch4, Ans)Values(combosubject.Text, txtsbcode.Text, Text1.Text, lblQno.caption, txtq.Text, opt1.Text, opt2.Text, opt3.Text, opt4.Text, real.Text,)")  

But there is an error pointed to this structure. Am i writing the proper way of using this syntax?
Was This Post Helpful? 0
  • +
  • -

#6 yobe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-August 12

Re: no value given for one or more required parameters vb6

Posted 07 August 2012 - 06:48 PM

I did specify the value in which column i want to insert it and i did provided the same number of values as the number of columns in the fields. And im pretty sure all the values i want to save are exist because i've try it to make it appear in "textbox".
Was This Post Helpful? 0
  • +
  • -

#7 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 271
  • View blog
  • Posts: 1,632
  • Joined: 26-March 09

Re: no value given for one or more required parameters vb6

Posted 07 August 2012 - 11:43 PM

Maybe you could tell us the error after you made the changes....Is the error the same, is it a different one?

What is the schema of the Questions table?

You specified 10 columns, 10 values, but you have an extra comma after the last value.
Was This Post Helpful? 0
  • +
  • -

#8 yobe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-August 12

Re: no value given for one or more required parameters vb6

Posted 08 August 2012 - 05:54 PM

con.Execute ("insert into Questions (Subjectname, Subjectcode, ExamID, Qno, Qst, Ch1, Ch2, Ch3, Ch4, Ans)Values('" + combosubject.Text + "'," + txtsbcode.Text + _
          ",'" + Text1.Text + "','" + lblQno.Caption + "','" + txtq.Text + _
         "','" + opt1.Text + "','" + opt2.Text + _
         "','" + opt3.Text + "','" + opt4.Text + "','" + real.Text + "')")



The problems solved with this code. Thank you for giving me the idea. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1