3 Replies - 3984 Views - Last Post: 07 September 2009 - 01:22 AM Rate Topic: -----

#1 syed_hassan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-September 09

how can i get specific record from acess database

Posted 07 September 2009 - 12:01 AM

hi i am new on this forum ... i want to create login form in VB.NET i will done a lot of work like inserting data and also retrieving data but i want to know that how can i get specific record from data base and want to match with my input ..... plz guide me.



Imports System.Data.OleDb

Public Class frmmain
	Dim da As OleDbDataAdapter
	Dim cmd As OleDbCommand
	Dim redred As OleDbDataReader
	Dim count As String
	Dim str As String
	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		frmadd.Show()
	End Sub

	

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim upass As String
		' Dim resu As String
		upass = Text2.Text

		Dim con As New OleDb.OleDbConnection
		Try
			con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = D:\project\login.mdb"
			con.Open()

			str = "select pass from table1 where pass = ('" + upass + "')"


			cmd = New OleDbCommand(str, con)

			cmd.ExecuteNonQuery()

			'While redred.Read()
			Label3.Text = redred("pass")
			'End While


			Text1.Text = ""
			Text2.Text = ""

			Label3.Text = "Opened"

		Catch ex As OleDb.OleDbException
			Label4.Text = "error"

		Finally
			con.Close()
			Label5.Text = "closed"

		End Try
	End Sub
End Class


This post has been edited by syed_hassan: 07 September 2009 - 12:02 AM


Is This A Good Question/Topic? 0
  • +

Replies To: how can i get specific record from acess database

#2 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: how can i get specific record from acess database

Posted 07 September 2009 - 12:08 AM

should this part

			cmd.ExecuteNonQuery()

			'While redred.Read()
			Label3.Text = redred("pass")
			'End While




not be

			redred =  cmd.ExecuteReader

			redred.Read()
			Label3.Text = redred("pass")
		  



Was This Post Helpful? 0
  • +
  • -

#3 syed_hassan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-September 09

Re: how can i get specific record from acess database

Posted 07 September 2009 - 01:15 AM

View Postmotcom, on 6 Sep, 2009 - 11:08 PM, said:

should this part

			cmd.ExecuteNonQuery()

			'While redred.Read()
			Label3.Text = redred("pass")
			'End While




not be

			redred =  cmd.ExecuteReader

			redred.Read()
			Label3.Text = redred("pass")
		  




thankx bro its working fine now :D
Was This Post Helpful? 0
  • +
  • -

#4 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: how can i get specific record from acess database

Posted 07 September 2009 - 01:22 AM

just remember,

the

redred.Read()



only reads one line/record in forward direction.

You can not go to the previous record.

if you want to go through all the records then use this

do while redred.Read()
	'action you want to do HERE.
loop


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1