LogonUser WebMethod

Posted on 2005-04-19
Last Modified: 2006-11-18
(This is the last conversion question - I promise.)

I have one more small block of code that I wasn't able to convert using C-Sharpener. I'm not including my partial conversion, since it will just make things messier. My version uses a SQL database instead of Access.

[ WebMethod() ]
        public int LogonUser() {
            int logonUserReturn = 0;
            if ( !( objConn.State == 1 ) ) { objConn.Open( strConnection, "", "", -1 ); }
            Object strUID = UniqueID();
            try {
                objRS = objConn.Execute( "INSERT INTO users (password,uniqueid) VALUES ('" + strUID + "', '" + strUID + "')", out null, -1 );
                objRS = objConn.Execute( "SELECT userid FROM users WHERE uniqueid='" + strUID + "'", out null, -1 );
                logonUserReturn = Int( objRS( 0 ).Value );
                objRS = null;
            catch  {
                logonUserReturn = 0;
            return logonUserReturn;

Sorry if this is an obvious question, I've been at this for a long time, and simply can't think straight any more. My main problems have been with the connection string. I'm also not sure why there is an out parameter being passed to the Execute method. (It would have helped if the source I'm converting was documented.)

Once I'm done, I'm takng a remedial course in VB.NET.
Question by:nh_capricorn
    LVL 1

    Accepted Solution

    I'm not sure exactly what your question is, but I'm pretty sure you can't have a parameter with a space in it (out null).  I don't see your connection string.  Is it there, and I'm just a moron?

    LVL 96

    Expert Comment

    by:Bob Learned
    Are you converting from VB.NET to C#?  Or, the other way around?

    Do you have the original code converted from?  Or, is this the original?


    Author Comment

    You were right. Parameters cannot have spaces in them.

    I am sorry that it took me this long to award you the points you earned. Guess I spaced it.

    Thanks again for your help.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now