creating user in asp.net sample

Please Note: Here iam writing description of code in comments

// creating user into database sample using Vb.net

Public Function Do_InsertUsrs(ByVal strConn As String, ByVal strDid As String, _
        ByVal strUid As String, ByVal strPwd As String) As Integer

Try
            Dim strSta As String
            strSta = "A"

            '' used to establish connection to database

            objConn = New OracleConnection(strConn)

	    '' opening the connection

            objConn.Open() 

	    '' begining the Transaction

            tx = objConn.BeginTransaction

            '' command to be executed ile., inserting record to database using parameters ile UID,Pwd Did

            objComm = New OracleCommand("INSERT INTO
DET_SELFPRINTING_USERS VALUES('" & strDid & "','" & strUid & "','" & strPwd & "')", objConn)

           objComm.Transaction = tx

	    '' Execute the Query it returns no of rows effected ile., 1

            iCnt = objComm.ExecuteNonQuery()

  '' checking if 1 row is executed successfully it displayes record saved

            If (iCnt = 1) Then
                tx.Commit()
                Return iCnt
            Else
                tx.Rollback()
                Throw New Exception("Faild to Create user try again")
            End If

        Catch ex As Exception
            Throw New Exception("User already exists ")

End Try

End Function

''when calling this method pass values to it as parameters

 Try
            iCnt = Do_InsertUsrs(strConn, Did, TxtUid.Text, TxtPwd.Text)
            If (iCnt = 1) Then
                Responce.Write("Record Saved Successfully")

                TxtUid.Text = ""
                TxtPwd.Text = ""
                TxtRPwd.Text = ""
            Else
               Responce.Write("Record Not Saved Successfully")
                TxtUid.Text = ""
                TxtPwd.Text = ""
                TxtRPwd.Text = ""
            End If
        Catch ex As Exception

                              Responce.Write(ex.Message)

 End Try

note: if there is any error in code please comment on thsi post i will try to find solution for the same

Advertisements

About kakani santosh kumar

Working as Software Engineer in Prithvi Information Solutions having 3 years of Experience in Dotnet Framework ranging from 1.1 to 3.5
This entry was posted in Database, Programming. Bookmark the permalink.

One Response to creating user in asp.net sample

  1. arun says:

    in the problem of unable to connect to asp.net development serve,,,i have downloaded(133kb) file from this but still i am getting the same problem when i have been executing(asp.netwebsite) for 4-5 times,,why is it so happening

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s