2
Answers

plz anybody convert my code from vb to c#

Shah Shishir

Shah Shishir

16y
2.5k
1
If txtPassword.Text = txtCpassword.Text Then

            Dim StrTempChar As String
            Dim i As Integer

            Dim MyPwd As String
            MyPwd = txtPassword.Text

            For i = 1 To Len(MyPwd)
                If Asc(Mid$(MyPwd, i, 1)) < 128 Then
                    StrTempChar = CType(Asc(Mid$(MyPwd, i, 1)) + 128, String)
                ElseIf Asc(Mid$(MyPwd, i, 1)) > 128 Then
                    StrTempChar = CType(Asc(Mid$(MyPwd, i, 1)) - 128, String)
                End If

                Mid$(MyPwd, i, 1) = Chr(CType(StrTempChar, Integer))
            Next i

            Conn.Open()
            Comm = New Data.SqlClient.SqlCommand
            Comm.Connection = Conn
            Comm.CommandType = Data.CommandType.Text
            Comm.CommandText = "Insert Into customer (Emailid,Password,Userid,Add1,State,City,Pin,Title,Fname,Lname,Gender,Dob,Mobile,Regidate) " & _
                " values('" & txtEmailid.Text & "','" & MyPwd & "','" & txtEmailid.Text & "','" & txtAdd1.Text & "','" & cmbState.SelectedItem.Text & "','" & txtCity.Text & "'," & txtPin.Text & ",'" & CmbTitle.SelectedItem.Text & "','" & txtFname.Text & "','" & txtLname.Text & "','" & cmbGender.SelectedItem.Text & "','" & BodDate.SelectedDate.Date & "'," & txtMobile.Text & ",'" & System.DateTime.Today & "')"
            Comm.ExecuteNonQuery()
            Conn.Close()

            Adpt = New Data.SqlClient.SqlDataAdapter("select * from customer", Conn)
            Dataset1 = New Data.DataSet
            Adpt.Fill(Dataset1, "customer")

            EmptyControls()
        Else
            'EmptyControls()
            lblMessage.Visible = True
            lblMessage.Text = "Try Again !.....Password and Confirm Password is not Match"
        End If



Thanks in advance
Plz solve my problem as early as possible
Shah Shishir

Answers (2)