Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Add User:
C#
public static int AddUser(Users  user)
        {
            OleDbParameter prmName = new OleDbParameter("@name", OleDbType.VarWChar,100);//datatype Text
            prmName.Value = user.Name;
            OleDbParameter prmPass = new OleDbParameter("@pass", OleDbType.VarWChar,100);
            prmPass.Value = user.Password;
            OleDbParameter prmEmail = new OleDbParameter("@email", OleDbType.VarWChar,100);
            prmEmail.Value = user.Email;

            return DataAccess.Execute("INSERT INTO User([Name],[Pass],[Email]) VALUES(@name,@pass,@email)", prmName, prmPass, prmEmail);
        }


Execute command:
C#
public static int Execute(string SPName, params OleDbParameter[] Parameters)
        {
            int intErr = 0;
            OleDbConnection cn = new OleDbConnection(ConnectionString);
            OleDbCommand cmd = new OleDbCommand(SPName, cn);

            cmd.CommandText = SPName;
            //cmd.CommandType = CommandType.Text;

            if (Parameters != null)
                foreach (OleDbParameter item in Parameters)
                {
                    cmd.Parameters.Add(item);
                }

            cn.Open();
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                intErr = 1;
                if (cn != null) cn.Close();
            }
            cn.Close();

            cmd = null;
            cn = null;

            return intErr;
        }
Posted
Updated 8-Oct-13 16:19pm
v3
Comments
ajitkmr09 8-Oct-13 22:36pm    
Please help me as soon as possible.Its urgent
ajitkmr09 8-Oct-13 23:14pm    
I found the solution.....
Its use the stored procedure by saving the query in access...
Thanks all and byeee
thatraja 9-Oct-13 9:03am    
You didn't tell the clearly that's why you didn't get answers. Anyway next time include complete details clearly in your upcoming questions. Come back again here when you need help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900