Tuesday, June 28, 2005

Database Connectivity and Query commands to execute in ASP.NET

This is the conenction string for access stroed in a variable strconn. This variable is passed as argument to the function in the function call. Here it is GETHEADLINES.
Public strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Database/naviwebpage.mdb")

The function returns a dataset of records of the query. the results should be stroed in the Dataset and can populated to any form.
Function fnGetHeadlines(ByVal strConn As String) As DataSet
Dim conn As New OleDbConnection(strConn)
conn.Open()
Dim cmd As New OleDbCommand("select Headlines,DetailNews from news", New OleDbConnection(strConn))
Dim myDataAdapter As New OleDbDataAdapter(cmd)
Dim myDataset As New DataSet
myDataAdapter.Fill(myDataset)
conn.Close()
Return myDataset
End Function


Comments Please

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home