troubleshooting Question

Cannot fill datatable.Using VB.Net,SQL procedure

Avatar of sarang8180
sarang8180 asked on
Visual Basic.NETMicrosoft SQL Server 2005
23 Comments1 Solution1244 ViewsLast Modified:
CODE OF VB.Net
dim dsUserLogin as new Dataset
daLogin.SelectCommand = GetSelectCommand(objConnection, UserName, Password)
                    .Fill(dsUserLogin,DSLogin.TestLoginTable)
                End With
                If dsUserLogin.Tables(0).Rows.Count = 1 Then
                    bol = True
                Else
                    bol = False

                End If
 Private Function GetSelectCommand(ByRef objConnection As SqlConnection, ByVal strUser As String, ByVal strPassword As String) As SqlCommand

            If bolUsernameCheck = True Then
                cmdSelect = New SqlCommand("SP_CheckValid", objConnection)
            Else
                cmdSelect = New SqlCommand("SP_CheckUserExist", objConnection)
            End If

            cmdSelect.CommandType = CommandType.StoredProcedure

            Try
                With cmdSelect.Parameters

                    .Add(New SqlParameter(Param_UserName, strUser))
                    .Add(New SqlParameter(Param_Password, strPassword))
                    GetSelectCommand = cmdSelect

                    If bolUsernameCheck = True Then

                        Dim i As Integer = cmdSelect.ExecuteScalar().ToString()
                        GetSelectCommand = cmdSelect
                    Else
                        objConnection.Open()
                        cmdSelect.ExecuteNonQuery()
                        Return cmdSelect
                    End If

                End With
            Catch ex As Exception

            End Try
        End Function
DSLogin.TestLoginTable is a class in which data columns of datatable dsUSerLogin are defined.
CODE OF SQL PROCEDURE

CREATE Procedure SP_CheckUserExist
@Username varchar(100),
@password  varchar(100)


as
       
    if exists(select *  from UserLogin where  upper(username)= upper(@username))
      
   Begin
           select 0
     end
  else
       
Begin
         insert into userlogin(username,pwd) values(@username,@password)
                  select 1
end
GO
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 23 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros