Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 11th, 2004, 01:45 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default Error while entering into database

Hi,

I am trying to insert a password and username into database. I am hashing the password first and then entering it into the database. When I submit the request Iget this error: -

Syntax error in INSERT INTO statement.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Source Error:


Line 28: // you're accessing an external resource that could fail.
Line 29: objConnection.Open();
Line 30: objCommand.ExecuteNonQuery();
Line 31: objConnection.Close();
Line 32: }


Source File: D:\House or Home Site\Admin\register.aspx Line: 30

Here is my code: -

<script language="C#" runat="server">

private void addUser(object sender, System.EventArgs e)
{
    string UserName = txtUserName.Text;
    string Password = txtPassword.Text;

    const string CONNSTR = "Provider=Microsoft.Jet.OleDb.4.0.; data source= D:\\House or Home site\\House.mdb;";//\\premfs3\\sites\\premium8\\adnanarab66\\database\ \House.mdb;";
    string hashedPwd = FormsAuthentication.HashPasswordForStoringInConfig File(Password,"SHA1");
    String strSQL = "INSERT INTO Users (UserName, Password) VALUES (?,?)";
    OleDbConnection objConnection = new OleDbConnection(CONNSTR);
    OleDbCommand objCommand = new OleDbCommand(strSQL, objConnection);
    objCommand.Parameters.Add("UserName", OleDbType.VarChar, 32, "UserName");
    objCommand.Parameters.Add("Password", OleDbType.VarChar, 32, "Password");

    objCommand.Parameters["UserName"].Value = UserName;
    objCommand.Parameters["Password"].Value = hashedPwd;

    // in real life add try--catch block because
    // you're accessing an external resource that could fail.
    objConnection.Open();
    objCommand.ExecuteNonQuery();
    objConnection.Close();
}

</script>

Any ideas??



Adz - The World is not enough
__________________
Adz - Learning The J2EE Ways.
 
Old April 12th, 2004, 07:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

How long is the password once SHA1 is applied?

 
Old April 12th, 2004, 01:52 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default

yeah got it thanks man

Adz - The World is not enough





Similar Threads
Thread Thread Starter Forum Replies Last Post
entering £ (pound sign) into MySQL database - PHP crmpicco PHP Databases 1 November 14th, 2007 02:02 AM
Entering data into an SQL database jmsherry SQL Server 2000 3 July 24th, 2007 01:00 AM
Error entering lengthy text into SQL Server ltdanp21 SQL Server 2000 1 June 1st, 2004 04:58 AM
Entering dates. mildge Beginning PHP 1 January 29th, 2004 07:24 PM
entering data Kelly Johnson Classic ASP Databases 1 August 7th, 2003 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.