create username and password for database dynamically - TechRepublic
Question
February 26, 2009 at 03:43 AM
ashok

create username and password for database dynamically

by ashok . Updated 17 years, 4 months ago

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.

This discussion is locked

All Comments