Visual basic

SQl Queries in vb

Page 1 of 1

2 Replies - 1165 Views - Last Post: 13 May 2008 - 12:45 AM Rate Topic: -----

#1 ganesh_pawar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-May 08

Visual basic

Post icon  Posted 08 May 2008 - 09:31 PM

I have need to Search database for Access using SQL Queries for
" Searching Date between 01/01/2008 to 10/01/2008 "
Is This A Good Question/Topic? 0
  • +

Replies To: Visual basic

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Visual basic

Posted 08 May 2008 - 09:35 PM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 anand_the_great  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 47
  • Joined: 15-April 08

Re: Visual basic

Posted 13 May 2008 - 12:45 AM

Hello Ganesh, if this your first time to do connection, you need to add a component.
Very easy, go to properties, select "References", add the Microsoft ActiveX Data Objects 2.0 Liabrary.
This is a code to insert in command1.

Public Sub Command1_Click()
Dim masql As String
Dim con As New adodb.Connection
Dim rs As New adodb.Recordset
Set con = New adodb.Connection
Set rs = New adodb.Recordset
rs.CursorLocation = adUseClient
con.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\wage.mdb"
con.Open
	masql = "SELECT * From Table1 WHERE Date BETWEEN '01/01/2008' And '10/01/2008'"


rs.Open masql, con, adOpenDynamic, adLockOptimistic
rs.MoveFirst
Set DataGrid1.DataSource = rs
End Sub

Take Care.
Anand.

This post has been edited by anand_the_great: 13 May 2008 - 12:50 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1