Problems with my drop Down list box

brooke2624

Member
Joined
Mar 13, 2006
Messages
5
Programming Experience
Beginner
I am currently working on a program that is allowing users to login to a database and look at their pay check details. I am having one problem though. I have created my login form with an employee id and password. I have gotten it to work and validate that both a employer Id and password exist. I then redirect it to a page with the check details. I have a label that displays their employer id number from the first page and then I have a drop down list box. I am trying to connect this drop down list box to the database, but I am having problems. I am only wanting to display the pay period for only the individual employee id number. Instead, it keeps displaying everyone's pay period numbers. I have also put in a for loop that only displays each record without showing identical records. The problem with this is that I might have an employee that hired in at pay period 3, but instead it still shows all of the pay period, but just not duplicates. Can someone please help me out???? I can't find anything about this in any books I have researched or on the net!!! Thanks a lot!!!!!
 
it sounds like the dropdown list of pay periods needs to be a query which is built to include criteria from your employee_id label. for example, you need a sql statement like "select pay_period from pay_periods where employee_id='" & label1.text & "';"
then use that SQL to obtain the list for your dropdown list.
 
I did try doing that. I have a line of code that reads

"Select count(*) from ppchecktest where kpppp (which is my pay period) = @Payperiod AND kemp# (which is my employee id column) = @EmpNo"
mycommand.parameters.add("@Payperiod", ddlpayperiod.selecteditem)
mycommand.parameters.add("@empno", lblempno.text)

ddlpayperiod is my drop down list

this doesn't work though for some odd reason. I figured that I could set up these parameters to verify that the empno is equal to what is in the label. This is how I verified my username and password on the login page and it works great. For some odd reason it doesn't like it when I use the same code for the drop down list box. Any more ideas???
 
which type of data connection are you using? System.Data.OleDb, System.Data.Odbc, etc? The syntax for setting parameters slightly varies based on the exact data-provider you are using... maybe you're parameters are not getting set?
 
ok.. I think that may be your problem... the syntax if your using OleDb is different for using parameters... here's an example of how I'm doing this:

sqlUpdateRelTbl.Append(" SELECT ? AS myOBID, ? AS myClass, ? AS myLeft, ? AS myRight;")

'note that the question mark is a parameter... you would need to eliminate your @PayPeriod, etc, and replace those with question marks... then I set the parameters this way:

'populate a command object
Dim oRelCmd As New System.Data.OleDb.OleDbCommand(sqlUpdateRelTbl.ToString, oConn)
oRelCmd.Parameters.Add("myOBID", OleDb.OleDbType.VarChar, 24)
oRelCmd.Parameters.Add("myClass", OleDb.OleDbType.VarChar, 50)
oRelCmd.Parameters.Add("myLeft", OleDb.OleDbType.VarChar, 24)
oRelCmd.Parameters.Add("myRight", OleDb.OleDbType.VarChar, 24)

'add the parameters for this specific object. make sure the order of these parameters matches the order of the question marks in the SQL statement
oRelCmd.Parameters(0).Value = relTbl.Value(iRel, "OBID")
oRelCmd.Parameters(1).Value = relTbl.Value(iRel, "Class")
oRelCmd.Parameters(2).Value = relTbl.Value(iRel, "Left")
oRelCmd.Parameters(3).Value = relTbl.Value(iRel, "Right")

'open the connection for the db operation
oConn.ConnectionString = sConnString
oConn.Open()

'commit the row to the db
oRelCmd.ExecuteNonQuery()

'memory cleanup
oConn.Dispose()
 
Back
Top