Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Andreas_1983

@Andreas_1983
About
Posts
5
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • No Designer View (VS2008 C++)
    A Andreas_1983

    Ah, that's perfect, thanks. Would've preferred the easier WinForm methods of having it in the solution, but not complaining :)

    C / C++ / MFC c++ csharp visual-studio help question

  • No Designer View (VS2008 C++)
    A Andreas_1983

    Hi, Thanks for the reply. I have the professional edition but still no luck :(

    C / C++ / MFC c++ csharp visual-studio help question

  • No Designer View (VS2008 C++)
    A Andreas_1983

    Hi, I'm using Visual Studio 2008 and seem to have a problem with the form designer. I'm new to MFC and want to create a project that allows me to use the form designer. I create a new MFC application form and all the code is created. When I build and run this project, there is a basic window with a few components. However, I can only seem to see the code for this application. Is it possible for my to open this in the form designer and manually edit the form in the editor rather than through code? Thanks

    C / C++ / MFC c++ csharp visual-studio help question

  • Efficient way of accessing a Boolean from SQL Server
    A Andreas_1983

    Thanks to both you guys :) I ended up making my SP simpler:

    ...
    SELECT [Valid] FROM tUsers WHERE ID = @ID
    ...

    I then used ExecuteScalar() and it works great! One question though, what if the value returned from the DB is NULL? I've set the column to disallow NULL values but I thought it should probably have something in the code too, just in case :) Lastly, is there a best practice for this sort of thing in terms of performance?

    C# database question sharepoint sql-server sysadmin

  • Efficient way of accessing a Boolean from SQL Server
    A Andreas_1983

    Hi, I don't know if this was more suited to the database message board or not but I think my question is more to do with my code rather than the database. I have a basic table with a few columns. One of them is a Bit type and is effectively a flag. All I want to do is get the flag value for a given ID. I've tried using an output parameter in a stored procedure but I don't know the best way of retrieving the flag value and converting it to a Boolean in code. I don't think a SqlDataReader is ideal because it's only one value I want to return.

    ALTER PROCEDURE SP_UserValid
    @ID INT,
    @Valid BIT OUTPUT
    AS
    SET NOCOUNT ON;
    SET @Valid = (SELECT [Valid] FROM tUsers WHERE ID = @ID)

    Here's my code:

    SqlConnection connection = new SqlConnection(_ConnectionString);
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = connection;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "SP_UserValid";
    cmd.Parameters.Add(new SqlParameter("@ID", userID));
    cmd.Parameters.Add(new SqlParameter("@Valid", bValid));
    cmd.Parameters["@Valid"].SqlDbType = SqlDbType.Bit;
    cmd.Parameters["@Valid"].Direction = ParameterDirection.InputOutput;

    connection.Open();
    cmd.ExecuteNonQuery();

    // How do I get the "Valid" as a Boolean value?

    cmd.Connection.Close()

    Thanks for looking :)

    C# database question sharepoint sql-server sysadmin
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups