Results 1 to 12 of 12

Thread: Help required

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    13

    Exclamation Help required

    Hi All,

    I am creating a project using VB, and I am new to VB, I am still a beginner, I need help in retrieving email address from database when I enter the username, I have added the code below, please review it and let me know, basically when I enter the username it has pull the email address and display in the label
    vb.net Code:
    1. Private cn As Odbc.OdbcConnection  'this is the connection object
    2.     Private rs As ADODB.Recordset   'this is the recordset object
    3.  
    4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    5.  
    6.         Dim con As New OleDb.OleDbConnection
    7.         Dim dbProvider As String
    8.         Dim dbSource As String
    9.         Dim ds As New DataSet
    10.         Dim da As OleDb.OleDbDataAdapter
    11.         Dim sql As String
    12.        
    13.         dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
    14.         dbSource = "Data Source = C:\auto_email\test.mdb"
    15.  
    16.         con.ConnectionString = dbProvider & dbSource
    17.  
    18.         con.Open()
    19.  
    20.         sql = "Select Email_address from test where Uname= & uname"
    21.         da = New OleDb.OleDbDataAdapter(sql, con)
    22.         MsgBox("Database is now open")
    23.  
    24.     End Sub
    In the above I am stuck at the sql statement as I have no idea how to refer the text box as the username i.e "& uname" it is the name of the text box, is it the right way, also then as I informed I need to paste the email address in the label and the name is label2, I am trying it as " label2.text=da" but I get a error message, I am using Visual basic professional 2010.

    Please help me in this.....
    Looking forward for your reply.
    Regards,
    Srinirao
    Last edited by Hack; Nov 18th, 2011 at 07:17 AM. Reason: Added Highlight Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width