Results 1 to 4 of 4

Thread: create username and password for database dynamically

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up create username and password for database dynamically

    Hi,

    I am using Asp.Net 2.0 application, First i have created database dynamically in my codebehind. well the db created successfully. Now i want to give username and password dynamically for my dynamically created database. Is it possible? If yes, please tell me how can we do?

    Try
    Dim strQuery As String

    strName = txtName.Value

    strQuery = "create database db" & strName & ""

    createDataBase(strQuery)

    Catch ex As Exception

    End Try

    End Sub
    'Function for create database
    Function createDataBase(ByVal strQuery)

    Try

    Dim blnResults As Boolean = False

    Dim intRowsAffected As Integer

    ConOpen()

    Try
    objCmd = New SqlCommand

    objCmd.Connection = objCnn

    objCmd.CommandType = CommandType.Text

    objCmd.CommandText = strQuery

    intRowsAffected = objCmd.ExecuteNonQuery()

    If intRowsAffected > 0 Then blnResults = True

    Catch ex As Exception

    createDataBase = ex.Message

    'MsgBox(ex.Message)

    Exit Try

    Finally

    ConClose()

    End Try

    Exit_Function:

    createDataBase = blnResults

    Catch ex As Exception

    End Try

    Return Nothing

    End Function

    The above one is created database dynamically in code behind. I need to create username and password dynamically in code behind.

    Hope yours reply.
    Failing to plan is Planning to fail

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: create username and password for database dynamically

    You can use sp_adduser

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up Re: create username and password for database dynamically

    Hi mendhak,

    I am not using windows mobile phone.I am using Asp.Net 2.0 web application.
    Failing to plan is Planning to fail

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: create username and password for database dynamically

    sp_addUser is a SQL Server function. Nothing to do with mobile phones or Compact Framework.

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