locked
How do u make a registration and login page with a Web srevice RRS feed

  • Question

  • User-12021981 posted

    So im kinda stuck i have to use a web service in asp to get, read , import data that u enter into a textbox to a Microsoft Access database, the code for the web service is as follows.This is only to add a new record i still have to find out how u read but this doesn't work.

    Please help if u can.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    using System.Data;

    using System.Text;
    using System.Data.OleDb;

    public partial class SubmitBook : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void submitbookbtn_Click(object sender, EventArgs e)
    {

    usedatabase useDb = new usedatabase(Request.PhysicalApplicationPath +
    "App_Code\\Bookwebsite.mdb");

    string Email = emailregTextbox.Text;
    string Password = passregTextbox.Text;
    string UserName = usernamelblreg.Text;
    string Surname = SurnameRegTextbox.Text;
    string Age = AgeRegTextbox.Text;

    {
    OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\user-pc\source\repos\BookWebsite\BookWebsite\App_Code\Bookwebsite.mdb");
    OleDbCommand cmmd = new OleDbCommand("INSERT INTO BookUsers ([Email], [Password], [UserName] , [Surname], [Age]) VALUES (@Email, @Password, @UserName, @Surname, @Age)", conn);

    cmmd.Parameters.Add("@Email", OleDbType.VarChar).Value = Email ;
    cmmd.Parameters.Add("@Password", OleDbType.VarChar).Value = Password;
    cmmd.Parameters.Add("@UserName", OleDbType.VarChar).Value = UserName;
    cmmd.Parameters.Add("@Surname", OleDbType.VarChar).Value = Surname;
    cmmd.Parameters.Add("@Age", OleDbType.VarChar).Value = Age;

    conn.Open();
    cmmd.ExecuteNonQuery();
    conn.Close();

    }
    }

    Friday, July 31, 2020 12:42 PM

All replies

  • User753101303 posted

    Hi,

    Never used OleDb much but AFAIK it uses ? rather than @name inside the SQL statement. What if you change the SQL statement to:

    INSERT INTO BookUsers ([Email], [Password], [UserName] , [Surname], [Age]) VALUES (?,?,?,?,?)

    If not that I see maybe 3 or 4 other possible issues so please always tell which error you have rather than just that "it doesn' work" so that we don"t have to guess first which problem  you are trying to solve.

    Friday, July 31, 2020 3:33 PM
  • User-12021981 posted

    Sorry for the confusion i made it more clear in aother post i first had to try and find the error.

    Friday, July 31, 2020 9:54 PM
  • User1535942433 posted

    Hi Clasuis,

    Accroding to your description,I don't understand your requirment clearly.Do you need to read records of users?What's your problems currently?

    I suggest you could use OleDbDataReader. Read Method.

    More details,you could refer to below article:

    https://docs.microsoft.com/en-us/dotnet/api/system.data.oledb.oledbdatareader.read?view=dotnet-plat-ext-3.1

    If you have other problems,you could tell us more details of your requirments.

    Best regards,

    Yijing Sun

    Tuesday, August 4, 2020 7:46 AM