Results 1 to 5 of 5

Thread: web application

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    64

    web application

    Hy,

    I need to know how can I connect my web form to an access database.
    Is it by edditing the web.config.
    or by creating an ordinar:
    OledConnection
    OledbDataadapter
    and a Dataset??

    I tried these methode but got errors in the dataadapter.fill.

    Please it's urgent tell me what to do.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    exmaple of getting access data into a dataset

    Code:
    Public rptCatagory As Repeater
    	Dim myDS As New DataSet
    	Dim myConn As OleDbConnection
    	Dim myCommand As OleDbDataAdapter
    	Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & System.Web.HttpContext.Current.Server.MapPath("test.mdb")
    	Dim strSQL As String
    	
    	Private Sub Page_Load(ByVal sender As Object, e As EventArgs)
    		' Get Catagory listing from db
    		strSQL = "SELECT c.ID, c.Catagory, c.PostCount, c.LastPostDate, c.Description, u.Username, u.ID AS UserID FROM Catagories AS c INNER JOIN Users AS u ON c.LastPostBy = u.ID"
    
    
    		' Populate the Dataset from the SQL statement
    		' Start Connection to ADO source
    		myConn = New OleDbConnection (strConnString)
    		' Run the Sql statement and get the Data into the DataAdapter
    		myCommand = New OleDbDataAdapter(strSQL, myConn)
    		' Fill the DataSet and name the table
    		myCommand.Fill(myDS, "Catagory")
    		myConn.Close()
    		
    		' Now set the DataGrid's source to the Dataset and bind it
    		rptCatagory.DataSource = myDS.Tables("Catagory").DefaultView
    		rptCatagory.DataBind()
    	End Sub
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    64

    Thanks

    Thank you Cander,

    the code you gave me, solved the problem, but how can I bind my data to a text fields, so that the user can navigate through the database?

    Please tell me if it is possible, and how can we do it.

    Thanks for your help.

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    not sure what you mean by navigate in a textbox?!?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    64

    Navigation

    Hi, once again.

    What I meant in navigation, is that I want to link a textbox to a field of my dataset, and went I navugate the data set by presseing the: First, Next, Previous, and Last buttons, data must directly changed in the text box.
    We use to be able to do this in a windows application by setting the DataBinding Property to the DataSet Field I want, but since I am not using the wizard and creating a dataset object in my project, I couldn't do this in code.
    So please help me in this it's really very urgent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width