Change existing SQL Server Database fetching code to MS Access

Last Reply on Jan 07, 2013 08:33 AM By Mudassar

Posted on Jan 07, 2013 08:32 AM

in my asp.net+vb code & sql database web i sused the folowing code to count and display the numbers in a web page.

now i have a access database and asp.net+vb code web how can i do the same now.

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim con As New SqlConnection
        con.ConnectionString = ConfigurationManager.ConnectionStrings("testConnectionString").ConnectionString
        con.Open()
        Dim qstr, qstr1, qstr2, qstr3, qstr4, qstr5 As String
        qstr = "select count(*) from DATA where SPECI='t1' AND code='4'"
        qstr1 = "select count(*) from DATA where SPECI='t2'AND code='4'"
        qstr2 = "select count(*) from DATA where SPECI='t3'AND code='4'"
        qstr3 = "select count(*) from DATA where SPECI='t4'AND code='4'"
        qstr4 = "select count(*) from DATA where SPECI='t5'AND code='4'"
        qstr5 = "select count(*) from DATA where SPECI='t6'AND code='4'"
 	Dim sqladp As New SqlDataAdapter(qstr, con)
        Dim sqladp1 As New SqlDataAdapter(qstr1, con)
        Dim sqladp2 As New SqlDataAdapter(qstr2, con)
        Dim sqladp3 As New SqlDataAdapter(qstr3, con)
        Dim sqladp4 As New SqlDataAdapter(qstr4, con)
        Dim sqladp5 As New SqlDataAdapter(qstr5, con)
	Dim dt, dt1, dt2, dt3, dt4, dt5 As New DataSet
        dt.Clear()
        dt1.Clear()
        dt2.Clear()
        dt3.Clear()
        dt4.Clear()
        dt5.Clear()
	sqladp.Fill(dt, "DATA")
        sqladp1.Fill(dt1, "DATA")
        sqladp2.Fill(dt2, "DATA")
        sqladp3.Fill(dt3, "DATA")
        sqladp4.Fill(dt4, "DATA")
        sqladp5.Fill(dt5, "DATA")
  	comdtxt1.Text = dt.Tables("DATA").Rows(0).Item(0)
        crittxt1.Text = dt2.Tables("DATA").Rows(0).Item(0)
        other1txt.Text = dt3.Tables("DATA").Rows(0).Item(0)
        ms1txt1.Text = dt4.Tables("DATA").Rows(0).Item(0)
        drdo1.Text = dt5.Tables("DATA").Rows(0).Item(0)
 End Sub

 

You are viewing reply posted by: Mudassar on Jan 07, 2013 08:33 AM.
Posted on Jan 07, 2013 08:33 AM

Change connection string and connect to Accces database and instead of SqlConnection you will need to use OLEDBConnection class