Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return One Record

Status
Not open for further replies.

BDW1969

IS-IT--Management
Aug 29, 2002
43
0
0
US
I have a textbox that I have the user enter a customer number and then they click the find button. The proble I have is that it looks to me like the every record in the db is being pulled and not filtered to just the one needed. Any help would be great.

Public Class frmNew
Inherits System.Windows.Forms.Form
Dim bLoading As Boolean
Dim bNewRow As Boolean
Dim MasterBindMgr As BindingManagerBase


Private Sub frmNew_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtFind.Focus()
MasterBindMgr = Me.BindingContext(DsMasterCust1, "tblMasterCustRecord")
End Sub

Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click

Dim iRecords As Integer

If txtFind.Text <> "" Then
bLoading = True
OleDbDataAdapter1.SelectCommand.Parameters("MCust").Value = txtFind.Text
DsMasterCust1.Clear()
iRecords = OleDbDataAdapter1.Fill(DsMasterCust1)
If iRecords = 0 Then
MessageBox.Show("Cust Number not Found!", "Entry Error")
txtFind.Focus()
Else
cmbCust.Focus()
End If
bLoading = False
Else
MessageBox.Show("You must enter a Cust Number.", "Entry Error")
txtFind.Focus()
End If
End Sub
 
where is the oledbcommand and how do you make that?
what does dsmastercust1.tables(0).rows.count give after the fill?

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source="C:\Documents and Settings\local\Desktop\DB Projects\MTU\DataFiles\MTU_be.mdb";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider="Microsoft.Jet.OLEDB.4.0";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False


OleDbConnection1

SELECT AccountName, Chargeable, CustNumber, CustStatus, DateClosed, Description, DiaryBy, DiaryDate, DiaryNote, Division, FirstName, Company, Instructions, LastName, Owner, ID, State, CompanyID
FROM TblMasterCustRecord

dsmastercust1.tables(0).rows shows 8585
 
first of all

Code:
OleDbDataAdapter1.SelectCommand.Parameters("MCust").Value = txtFind.Text

should be this

Code:
OleDbDataAdapter1.SelectCommand.Parameters("@Cust").Value = txtFind.Text

and this

Code:
SELECT     AccountName, Chargeable, CustNumber, CustStatus, DateClosed, Description, DiaryBy, DiaryDate, DiaryNote, Division, FirstName, Company, Instructions, LastName, Owner, ID, State, CompanyID
FROM         TblMasterCustRecord

should probably be this

Code:
SELECT     AccountName, Chargeable, CustNumber, CustStatus, DateClosed, Description, DiaryBy, DiaryDate, DiaryNote, Division, FirstName, Company, Instructions, LastName, Owner, ID, State, CompanyID
FROM         TblMasterCustRecord
WHERE custnumber = @cust

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top