Solved

Search button VB 2010

Posted on 2011-02-20
13
1,265 Views
Last Modified: 2012-05-11
Hello all,

I have a problem with my search button.



 Private Sub rechercher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rechercher.Click
        Dim sSQL1 As String
        Dim oRST1 As ADODB.Recordset
        oRST1 = New ADODB.Recordset
        Dim oConnect1 As ADODB.Connection
        oConnect1 = New ADODB.Connection


        oConnect1.Open("Provider=Microsoft.ACE.OLEDB.12.0;" & _
       "Data Source=" & Parametre.txtBaseDelabsolution.Text)


        sSQL1 _
                = " SELECT [Nom],[Prénom],[Compagnie],[Adresse],[Ville],[Code_Postal],[Téléphone],[Cellulaire],[Courriel],[Courriel2],[Commentaire]" _
                & " FROM [Clients]" _
                & " WHERE Nom = '" & Nom_famille.Text & "'" _
                & "   AND Prénom = '" & prenom_prenom.Text & "'"




        oRST1.Open(sSQL1, oConnect1)

        If oRST1.BOF = False Then

            If Nom > "" Then
                oRST1.Filter = "Nom = '" & Nom.Text & "'"


                Me.compagnie.DataBindings = oRST1
                Me.compagnie.DataField = "Compagnie"



            End If
        End If
    End Sub

Open in new window



I have a problem with : If Nom > "" Then

and also with:
                Me.compagnie.DataBindings = oRST1
                Me.compagnie.DataField = "Compagnie"

It say:
Error      3      'DataField' is not a member of 'System.Windows.Forms.TextBox'.      
Error      2      Property 'DataBindings' is 'ReadOnly'.      


What could be the problem.

Thanks for your help

0
Comment
Question by:Wilder1626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
13 Comments
 
LVL 11

Author Comment

by:Wilder1626
ID: 34938834
I also tried like this, but still the same error


Me.compagnie.DataBindings = (oRST1("Compagnie").Value)
                compagnie.Text = "Compagnie"

Open in new window

0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34946700
Hi!

for you this problem: (or line 26 of your attached code)
If Nom > "" Then  

Open in new window


change it to this:
 If Not String.IsNullOrEmpty(Nom) Then

Open in new window


for your other problems of binding please read this:
http://support.microsoft.com/kb/189852

a part from link for your concern:
          Set Text1.DataSource = rsProducts
          Text1.DataField = "ProductName"

Open in new window


0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34947880
Ok,

The first part look's good but for the second part, still have a problem.

compagnie_nom.DataSource = oRST1
                compagnie_nom.DataField = "Compagnie"

Open in new window




Full code with access dbase:

     
 Dim sSQL1 As String
        Dim oRST1 As ADODB.Recordset
        oRST1 = New ADODB.Recordset
        Dim oConnect1 As ADODB.Connection
        oConnect1 = New ADODB.Connection


        oConnect1.Open("Provider=Microsoft.ACE.OLEDB.12.0;" & _
       "Data Source=" & Parametre.txtBaseDelabsolution.Text)


        sSQL1 _
                = " SELECT [Nom],[Prénom],[Compagnie],[Adresse],[Ville],[Code_Postal],[Téléphone],[Cellulaire],[Courriel],[Courriel2],[Commentaire]" _
                & " FROM [Clients]" _
                & " WHERE Nom = '" & Nom_famille.Text & "'" _
                & "   AND Prénom = '" & prenom_prenom.Text & "'"




        oRST1.Open(sSQL1, oConnect1)

        If oRST1.BOF = False Then

            If Not String.IsNullOrEmpty("Nom") Then
                oRST1.Filter = "Nom = '" & Nom_famille.Text & "'"


                compagnie_nom.DataSource = oRST1
                compagnie_nom.DataField = "Compagnie"

                service_offert.Enabled = True

                service_offert.Select()
            End If
        End If

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34954866
Hi!

1) What problem did you get now ???
2) To which object this is "compagnie_nom" representing ???
3) Did you try to change line 29 like this:
    Set compagnie_nom.DataSource = oRST1

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34955414
compagnie_nom = a textbox.

When i put     Set compagnie_nom.DataSource = oRST1, the set disapear and it under line compagnie_nom.DataSource
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34955448
What i will do is that i will send you the print screen of the issue in about 2:30 hours, when i will get home.
0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34955472
Did you get any ERROR message or simply underline ???
Reply when feasible.

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34956662
Hello

The error i have is:


Error      3      'DataField' is not a member of 'System.Windows.Forms.TextBox'.      


Error      2      'DataSource' is not a member of 'System.Windows.Forms.TextBox'.
0
 
LVL 19

Accepted Solution

by:
Shahan Ayyub earned 500 total points
ID: 34963103
Hmmm....

Check this link:
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/95a996ff-db85-4409-86b7-b266f5d20276/

A part from link:
Me.TextBox1.DataBindings.Add("Text", ObjRS, "ACCOUNT#")

Open in new window

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34966156
Hello .

here is the new result after reading the link:

Me.compagnie_nom.Text = oRST1.Fields.Item(0).Value.ToString
                Me.compagnie_nom.DataBindings.Add("Text", oRST1, "Compagnie")

Open in new window


But now, it give me an eror on:
Me.compagnie_nom.DataBindings.Add("Text", oRST1, "Compagnie")

Open in new window


Error mesgae:

System.ArgumentException was unhandled
  Message=Impossible d'effectuer une liaison à la propriété ou la colonne Compagnie sur le DataSource. (Imposible to link to column "Compagnie" on the datasource.

Nom du paramètre : dataMember
  ParamName=dataMember
  Source=System.Windows.Forms
 
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 34966282
Thanks a lot. I was able with your help to find the way



 'Compagnie
                Me.compagnie_nom.Text = oRST1.Fields.Item(2).Value.ToString

                'adress_1
                Me.adress_1.Text = oRST1.Fields.Item(3).Value.ToString

                'city_1
                Me.city_1.Text = oRST1.Fields.Item(4).Value.ToString

                'zip_code
                Me.zip_code.Text = oRST1.Fields.Item(5).Value.ToString

                'phone_1
                Me.phone_1.Text = oRST1.Fields.Item(6).Value.ToString

                'cell_1
                Me.cell_1.Text = oRST1.Fields.Item(7).Value.ToString

                'email_1
                Me.email_1.Text = oRST1.Fields.Item(8).Value.ToString
0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34969547
Glad to see that your problem resolved :)
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question