mechwarrior3
Well-known member
- Joined
- Dec 19, 2005
- Messages
- 67
- Programming Experience
- Beginner
How does a parameter get a default value? (RESOLVED)
Hello everyone,
I have attached an image of the exception I continue to smash my head into even as I make this post. This exception occurs in this little block of code:
What I want to do is see if there are any records within my database that match the two parameters at the same time within the SELECT statement. Essentially, I should only have one record or no records that correctly match the two parameters within the SELECT statement. I read that the .Fill method returns an integer value signifying the amount of rows filled within the data set so that is why I am using the integer, verify, to see just how many rows were filled. Why do I get the error about the parameter not having a default value?
I use data adapters and the .Fill command in other parts of my code and have not encountered this problem. I am having trouble finding anything within my code that could explain this problem.
Any help is greatly appreciated. Thanks, everyone.
Hello everyone,
I have attached an image of the exception I continue to smash my head into even as I make this post. This exception occurs in this little block of code:
VB.NET:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] verify [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] AccessConn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDb.OleDbConnection(MYACCESSCONN)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] AccessAdapter [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDb.OleDbDataAdapter
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] AccessDataSet [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Data.DataSet
AccessAdapter.SelectCommand = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDb.OleDbCommand("SELECT * FROM tbl_HCI_Lot_Inspection_Data WHERE strLotNumber = ? AND strMixID = ?")
AccessAdapter.SelectCommand.Connection = AccessConn
AccessAdapter.SelectCommand.Parameters.Add("@MfgNum", OleDb.OleDbType.VarChar, 50, "strLotNumber")
AccessAdapter.SelectCommand.Parameters.Add("@MixNum", OleDb.OleDbType.VarChar, 50, "strMixID")
[/SIZE][SIZE=2][COLOR=#008000]' The .Fill routine returns the number of rows filled with data so in our case, as long as there is one row
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' filled, we have verified that the record exists within the database.
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]verify = AccessAdapter.Fill(AccessDataSet, "tbl_HCI_Lot_Inspection_Data")
[/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] sqlEx [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] OleDb.OleDbException
MessageBox.Show(sqlEx.ToString)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' verify = AccessAdapter.Fill(AccessDataSet, "tbl_HCI_Inspection_Lot_Data")
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] (verify >= 1) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]blnThere = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=2]blnThere = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
What I want to do is see if there are any records within my database that match the two parameters at the same time within the SELECT statement. Essentially, I should only have one record or no records that correctly match the two parameters within the SELECT statement. I read that the .Fill method returns an integer value signifying the amount of rows filled within the data set so that is why I am using the integer, verify, to see just how many rows were filled. Why do I get the error about the parameter not having a default value?
I use data adapters and the .Fill command in other parts of my code and have not encountered this problem. I am having trouble finding anything within my code that could explain this problem.
Any help is greatly appreciated. Thanks, everyone.
Attachments
Last edited: