Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Unanswered: can some one help me pls

    ian using visual studio 2005 to gesign my asp pages and i have aa access database to hold few important information
    the problem is iam not able to connect to it to upload new valuse

    its like i have a forum from which i get the new entries from the customers and upload it to the data base
    my code is like this


    Imports System.Data.OleDb
    Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

    Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=MyDB.mdb;")
    Dim da As New OleDbDataAdapter("select * from emp", cn)
    Dim dt As New Data.DataTable
    da.Fill(dt)
    da.Dispose()
    cn.Dispose()
    Me.GridView1.DataSource = dt
    Me.GridView1.DataBind()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=MyDB.mdb;")
    Dim cmd As New OleDbCommand
    With cmd
    .CommandText = "insert into emp (Empno,Ename,Sal,Deptno) values (" & Me.TextBox1.Text & ",'" & Me.TextBox2.Text & "'," & Me.TextBox3.Text & "," & Me.TextBox4.Text & ")"
    .Connection = cn
    .Connection.Open()
    .ExecuteNonQuery()
    .Connection.Close()
    .Dispose()
    End With
    cn.Dispose()
    'refresh the list
    'btnList_Click(Nothing, Nothing)




    End Sub
    End Class

    the button one is used to add the entered datas into the data base
    and the second button to view the updated databse

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Welcome to the forum

    I'm going to move this post to the ASP section where you're more likely to get a targetted response.
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    ...so do you get any error messages?
    Can you construct the command string for the insert command in a variable, then .Write that, finally pasting the results back here so we can see?
    George
    Home | Blog

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Look in to "prepared statements". They will probably solve a number of your current headaches.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Aug 2008
    Posts
    12
    Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=MyDB.mdb;")

    my experience is that DataSource=

    needs to be followed by a path...either locally or url

    i.e. c:\temp\MyDB.mdb

Posting Permissions

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