What is wrong with this Select SQL query

Lums

Member
Joined
Feb 9, 2010
Messages
22
Programming Experience
Beginner
SELECT Comment FROM [Comments] WHERE UPN = '" & upnpass & "' AND TestID =" & idpass & ""


Error : No value given for one or more required parameters.



Its ment to select data based on the values of 2 variables on my form any ideas?
 
Where are you trying to run this query? Is this in code? If it is in code could you post all the code that deals with connection objects, command objects and such.
 
heres all the code

Private Sub Criteria_Values_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.UserTableAdapter.Fill(Me.Database_DesignDataSet.User)
editbtn.Enabled = False
idpass = TestDetailsForm.idvar
idbx.Text = idpass
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = f:\Docs\College\Computing\CW\Form\VB Forms\VB Forms\Database Design.mdb"
con.Open()
sql = "SELECT [Test Criteria].Criteria, [Test Criteria].Value FROM [Test Criteria] WHERE [Test Criteria].TestID ='" & idpass & "' ;"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "TestCriteria")
con.Close()
maxrows = ds.Tables("TestCriteria").Rows.Count
inc = -1
DisableCloseButton(Me.Handle)
End Sub
Private Sub CriteriaTestFormula()
For Me.i = 0 To maxrows - 1
For Me.h = 1 To maxrows
Me.Controls.Item("TextBox" & Me.h).Text = ds.Tables("TestCriteria").Rows(Me.i).Item(0)


CType(Me.Controls.Item("NumericUpDown" & Me.h), NumericUpDown).Value = Convert.ToDecimal(ds.Tables("TestCriteria").Rows(Me.i).Item(1))
Next
Next
 
Query

Are you getting an error? or just no rows returned? You only have to use the ' character with string data.

Ty
 
Back
Top