Results 1 to 2 of 2

Thread: Convert functions to C#

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Convert functions to C#

    I wrote this functions while doing ASP programming, but now that I am doing C# programming, I was wondering if it would be possible to convert my ASP functions into C#? They are primarily for database actions (i.e. opening, querying, closing)

    VB Code:
    1. function db_open(connectionStringPayload)
    2.    if isObject(objConn) then
    3.       if objConn.state = 0 then
    4.          set objConn = server.createObject("ADODB.CONNECTION")
    5.          objConn.open connectionStringPayload
    6.          db_open = true
    7.       else
    8.          db_open = false
    9.       end if
    10.    else
    11.       set objConn = server.createObject("ADODB.CONNECTION")
    12.       objConn.open connectionStringPayload
    13.       db_open = true
    14.    end if
    15. end function
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Here's an exact translation to C#, but you'd want to use ASP.Net instead.
    Code:
    bool db_open(string connectionStringPayload)
    {
       if(objConn != null) {
          if(objConn.state == 0) {
             objConn = server.createObject("ADODB.CONNECTION");
             objConn.open(connectionStringPayload);
             return true;
          } else {
             return false;
          }
       } else {
          objConn = server.createObject("ADODB.CONNECTION");
          objConn.open(connectionStringPayload);
          return true;
       }
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width