|
-
Nov 18th, 2011, 05:24 AM
#1
Thread Starter
New Member
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:
Private cn As Odbc.OdbcConnection 'this is the connection object
Private rs As ADODB.Recordset 'this is the recordset object
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = C:\auto_email\test.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "Select Email_address from test where Uname= & uname"
da = New OleDb.OleDbDataAdapter(sql, con)
MsgBox("Database is now open")
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|