Inserting to Access Database

Discussion in 'ASP .Net' started by MA P, Sep 4, 2006.

  1. MA P

    MA P Guest

    Hi!

    Need help. I want to insert values from textbox-based input and upon
    clicking the Create button, these command lines will run. It didn't work! It
    points to the "test.Insert()" line that indicates that "Keyword not
    supported: 'provider'". See the code behind below:

    Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles btnCreate.Click
    Dim test As SqlDataSource = New SqlDataSource()
    test.ConnectionString =
    ConfigurationManager.ConnectionStrings("dbaccountsCS").ToString
    test.InsertCommand = "INSERT INTO [tblaccounts] ([UserName],
    [FName], [LName], , [Department],[Password]) VALUES (@UserName,
    @FName, @LName, @Email, @Dept, @Password)"

    test.InsertParameters.Add("UserName", txtUserName.Text)
    test.InsertParameters.Add("FName", txtFName.Text)
    test.InsertParameters.Add("LName", txtLName.Text)
    test.InsertParameters.Add("Email", txtEmail.Text)
    test.InsertParameters.Add("Dept", ddlDept.Text)
    test.InsertParameters.Add("Password", txtPass.Text)

    test.Insert() <<<<<<<<------ This line has an error

    Label7.Visible = True

    End Sub
     
    MA P, Sep 4, 2006
    #1
    1. Advertising

  2. Hi

    This definitely is a problem with the connection string. Why don't you post
    your connection string here ? It would help to narrow down the problem.

    Prem

    "MA P" wrote:

    > Hi!
    >
    > Need help. I want to insert values from textbox-based input and upon
    > clicking the Create button, these command lines will run. It didn't work! It
    > points to the "test.Insert()" line that indicates that "Keyword not
    > supported: 'provider'". See the code behind below:
    >
    > Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles btnCreate.Click
    > Dim test As SqlDataSource = New SqlDataSource()
    > test.ConnectionString =
    > ConfigurationManager.ConnectionStrings("dbaccountsCS").ToString
    > test.InsertCommand = "INSERT INTO [tblaccounts] ([UserName],
    > [FName], [LName], , [Department],[Password]) VALUES (@UserName,
    > @FName, @LName, @Email, @Dept, @Password)"
    >
    > test.InsertParameters.Add("UserName", txtUserName.Text)
    > test.InsertParameters.Add("FName", txtFName.Text)
    > test.InsertParameters.Add("LName", txtLName.Text)
    > test.InsertParameters.Add("Email", txtEmail.Text)
    > test.InsertParameters.Add("Dept", ddlDept.Text)
    > test.InsertParameters.Add("Password", txtPass.Text)
    >
    > test.Insert() <<<<<<<<------ This line has an error
    >
    > Label7.Visible = True
    >
    > End Sub
    >
    >
    > [/color]
     
    =?Utf-8?B?UHJlbSBLdW1hcg==?=, Sep 4, 2006
    #2
    1. Advertising

  3. MA P

    MA P Guest

    Here is the connection string:

    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AccessDB\Test\dbaccounts.mdb

    "Prem Kumar" <> wrote in message
    news:...
    > Hi
    >
    > This definitely is a problem with the connection string. Why don't you
    > post
    > your connection string here ? It would help to narrow down the problem.
    >
    > Prem
    >
    > "MA P" wrote:
    >
    >> Hi!
    >>
    >> Need help. I want to insert values from textbox-based input and upon
    >> clicking the Create button, these command lines will run. It didn't work!
    >> It
    >> points to the "test.Insert()" line that indicates that "Keyword not
    >> supported: 'provider'". See the code behind below:
    >>
    >> Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As
    >> System.EventArgs) Handles btnCreate.Click
    >> Dim test As SqlDataSource = New SqlDataSource()
    >> test.ConnectionString =
    >> ConfigurationManager.ConnectionStrings("dbaccountsCS").ToString
    >> test.InsertCommand = "INSERT INTO [tblaccounts] ([UserName],
    >> [FName], [LName], , [Department],[Password]) VALUES (@UserName,
    >> @FName, @LName, @Email, @Dept, @Password)"
    >>
    >> test.InsertParameters.Add("UserName", txtUserName.Text)
    >> test.InsertParameters.Add("FName", txtFName.Text)
    >> test.InsertParameters.Add("LName", txtLName.Text)
    >> test.InsertParameters.Add("Email", txtEmail.Text)
    >> test.InsertParameters.Add("Dept", ddlDept.Text)
    >> test.InsertParameters.Add("Password", txtPass.Text)
    >>
    >> test.Insert() <<<<<<<<------ This line has an error
    >>
    >> Label7.Visible = True
    >>
    >> End Sub
    >>
    >>
    >> [/color][/color]
     
    MA P, Sep 4, 2006
    #3
  4. MA P

    Mark Rae Guest

    "MA P" <> wrote in message
    news:Or3A64$...

    > Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=C:\AccessDB\Test\dbaccounts.mdb


    1) Just a thought, but I presume that "C:\" in the above string refers to
    the webserver's C:\ drive and not your own C:\drive, and that the database
    file is actually there...?

    2) Does the user that your site is running under have read/write permissions
    not only on the file but also on the folder in which the file resides? The
    Jet engine creates a locking database (.ldb) file in the same folder as the
    database file whenever the file is opened, and removes it when the file is
    closed...
     
    Mark Rae, Sep 4, 2006
    #4
  5. MA P

    MA P Guest

    I am still on the debugging stage of VWDE. I haven't deploy my web app.
    Remember that the error that I am telling is "Keyword not supported". Please
    review my original post.

    "Mark Rae" <> wrote in message
    news:...
    > "MA P" <> wrote in message
    > news:Or3A64$...
    >
    >> Provider=Microsoft.Jet.OLEDB.4.0;Data
    >> Source=C:\AccessDB\Test\dbaccounts.mdb

    >
    > 1) Just a thought, but I presume that "C:\" in the above string refers to
    > the webserver's C:\ drive and not your own C:\drive, and that the database
    > file is actually there...?
    >
    > 2) Does the user that your site is running under have read/write
    > permissions not only on the file but also on the folder in which the file
    > resides? The Jet engine creates a locking database (.ldb) file in the same
    > folder as the database file whenever the file is opened, and removes it
    > when the file is closed...
    >
     
    MA P, Sep 5, 2006
    #5
  6. MA P

    MA P Guest

    Then reason for using SQLDataSource instead of AccessDataSource is I want to
    separate Web Apps to the database. I don't know if its possible with
    SQLDataSource. Hope you might help.
    "MA P" <> wrote in message
    news:...
    >I am still on the debugging stage of VWDE. I haven't deploy my web app.
    >Remember that the error that I am telling is "Keyword not supported".
    >Please review my original post.
    >
    > "Mark Rae" <> wrote in message
    > news:...
    >> "MA P" <> wrote in message
    >> news:Or3A64$...
    >>
    >>> Provider=Microsoft.Jet.OLEDB.4.0;Data
    >>> Source=C:\AccessDB\Test\dbaccounts.mdb

    >>
    >> 1) Just a thought, but I presume that "C:\" in the above string refers to
    >> the webserver's C:\ drive and not your own C:\drive, and that the
    >> database file is actually there...?
    >>
    >> 2) Does the user that your site is running under have read/write
    >> permissions not only on the file but also on the folder in which the file
    >> resides? The Jet engine creates a locking database (.ldb) file in the
    >> same folder as the database file whenever the file is opened, and removes
    >> it when the file is closed...
    >>

    >
    >
     
    MA P, Sep 5, 2006
    #6
  7. MA P

    Guest

    Suggest using a large text file (like an ini file) then looping through
    each row.

    The Master


    MA P wrote:
    > Then reason for using SQLDataSource instead of AccessDataSource is I want to
    > separate Web Apps to the database. I don't know if its possible with
    > SQLDataSource. Hope you might help.
    > "MA P" <> wrote in message
    > news:...
    > >I am still on the debugging stage of VWDE. I haven't deploy my web app.
    > >Remember that the error that I am telling is "Keyword not supported".
    > >Please review my original post.
    > >
    > > "Mark Rae" <> wrote in message
    > > news:...
    > >> "MA P" <> wrote in message
    > >> news:Or3A64$...
    > >>
    > >>> Provider=Microsoft.Jet.OLEDB.4.0;Data
    > >>> Source=C:\AccessDB\Test\dbaccounts.mdb
    > >>
    > >> 1) Just a thought, but I presume that "C:\" in the above string refers to
    > >> the webserver's C:\ drive and not your own C:\drive, and that the
    > >> database file is actually there...?
    > >>
    > >> 2) Does the user that your site is running under have read/write
    > >> permissions not only on the file but also on the folder in which the file
    > >> resides? The Jet engine creates a locking database (.ldb) file in the
    > >> same folder as the database file whenever the file is opened, and removes
    > >> it when the file is closed...
    > >>

    > >
    > >
     
    , Sep 5, 2006
    #7
  8. Hi

    Just a try, came across in a forum.

    Remove the provider attribute and see what happens.

    Prem

    "MA P" wrote:

    > Here is the connection string:
    >
    > Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AccessDB\Test\dbaccounts.mdb
    >
    > "Prem Kumar" <> wrote in message
    > news:...
    > > Hi
    > >
    > > This definitely is a problem with the connection string. Why don't you
    > > post
    > > your connection string here ? It would help to narrow down the problem.
    > >
    > > Prem
    > >
    > > "MA P" wrote:
    > >
    > >> Hi!
    > >>
    > >> Need help. I want to insert values from textbox-based input and upon
    > >> clicking the Create button, these command lines will run. It didn't work!
    > >> It
    > >> points to the "test.Insert()" line that indicates that "Keyword not
    > >> supported: 'provider'". See the code behind below:
    > >>
    > >> Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As
    > >> System.EventArgs) Handles btnCreate.Click
    > >> Dim test As SqlDataSource = New SqlDataSource()
    > >> test.ConnectionString =
    > >> ConfigurationManager.ConnectionStrings("dbaccountsCS").ToString
    > >> test.InsertCommand = "INSERT INTO [tblaccounts] ([UserName],
    > >> [FName], [LName], , [Department],[Password]) VALUES (@UserName,
    > >> @FName, @LName, @Email, @Dept, @Password)"
    > >>
    > >> test.InsertParameters.Add("UserName", txtUserName.Text)
    > >> test.InsertParameters.Add("FName", txtFName.Text)
    > >> test.InsertParameters.Add("LName", txtLName.Text)
    > >> test.InsertParameters.Add("Email", txtEmail.Text)
    > >> test.InsertParameters.Add("Dept", ddlDept.Text)
    > >> test.InsertParameters.Add("Password", txtPass.Text)
    > >>
    > >> test.Insert() <<<<<<<<------ This line has an error
    > >>
    > >> Label7.Visible = True
    > >>
    > >> End Sub
    > >>
    > >>
    > >> [/color][/color]
    >
    >
    > [/color]
     
    =?Utf-8?B?UHJlbSBLdW1hcg==?=, Sep 5, 2006
    #8
  9. MA P

    MA P Guest

    How can I remove the provider attribute since it was automatically set by
    VWD.
    "Prem Kumar" <> wrote in message
    news:...
    > Hi
    >
    > Just a try, came across in a forum.
    >
    > Remove the provider attribute and see what happens.
    >
    > Prem
    >
    > "MA P" wrote:
    >
    >> Here is the connection string:
    >>
    >> Provider=Microsoft.Jet.OLEDB.4.0;Data
    >> Source=C:\AccessDB\Test\dbaccounts.mdb
    >>
    >> "Prem Kumar" <> wrote in message
    >> news:...
    >> > Hi
    >> >
    >> > This definitely is a problem with the connection string. Why don't you
    >> > post
    >> > your connection string here ? It would help to narrow down the problem.
    >> >
    >> > Prem
    >> >
    >> > "MA P" wrote:
    >> >
    >> >> Hi!
    >> >>
    >> >> Need help. I want to insert values from textbox-based input and upon
    >> >> clicking the Create button, these command lines will run. It didn't
    >> >> work!
    >> >> It
    >> >> points to the "test.Insert()" line that indicates that "Keyword not
    >> >> supported: 'provider'". See the code behind below:
    >> >>
    >> >> Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As
    >> >> System.EventArgs) Handles btnCreate.Click
    >> >> Dim test As SqlDataSource = New SqlDataSource()
    >> >> test.ConnectionString =
    >> >> ConfigurationManager.ConnectionStrings("dbaccountsCS").ToString
    >> >> test.InsertCommand = "INSERT INTO [tblaccounts] ([UserName],
    >> >> [FName], [LName], , [Department],[Password]) VALUES (@UserName,
    >> >> @FName, @LName, @Email, @Dept, @Password)"
    >> >>
    >> >> test.InsertParameters.Add("UserName", txtUserName.Text)
    >> >> test.InsertParameters.Add("FName", txtFName.Text)
    >> >> test.InsertParameters.Add("LName", txtLName.Text)
    >> >> test.InsertParameters.Add("Email", txtEmail.Text)
    >> >> test.InsertParameters.Add("Dept", ddlDept.Text)
    >> >> test.InsertParameters.Add("Password", txtPass.Text)
    >> >>
    >> >> test.Insert() <<<<<<<<------ This line has an error
    >> >>
    >> >> Label7.Visible = True
    >> >>
    >> >> End Sub
    >> >>
    >> >>
    >> >>[/color]
    >>
    >>
    >> [/color][/color]
     
    MA P, Sep 6, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrija
    Replies:
    1
    Views:
    816
    William Ryan
    Oct 5, 2003
  2. Alan Chiew
    Replies:
    0
    Views:
    351
    Alan Chiew
    Sep 23, 2003
  3. Replies:
    0
    Views:
    399
  4. wjer
    Replies:
    1
    Views:
    490
    Alvin Bruney [MVP]
    Mar 2, 2004
  5. Shapper
    Replies:
    2
    Views:
    573
    Paul Clement
    Jul 7, 2005
Loading...

Share This Page