Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am suppose to run a stored procedure.. and I will get a null or true output from the SP.

 

but I am lost on how to do this..

 

here is my code:

 

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim MyConnection As New OleDbConnection("Provider=SQLOLEDB.1;User Id=" & TextBox1.Text & ";Password=" & TextBox2.Text & ";Initial Catalog=WeGIR Member Data;Data Source=secure.server.com;Use Encryption for Data=True")
       'Dim ds As DataSet
       'Dim da As OleDbDataAdapter
       Dim myCmd As New OleDb.OleDbCommand("sp_ValidateLogin")
       Dim myReader As OleDb.OleDbDataReader

       myCmd.Connection = MyConnection
       myCmd.CommandType = CommandType.StoredProcedure

       Try
           MyConnection.Open()
           TextBox3.Text = "database open"

           'Dim ValidateLogin As String = "EXECUTE sp_ValidateLogin"
           'Dim Results As New OleDbDataAdapter(ValidateLogin, MyConnection)
           'ds = New DataSet
           'da.Fill(ds, "Results")

           myReader = myCmd.ExecuteReader()

           Do While myReader.Read
               TextBox4.Text = myReader.Read
           Loop

           myReader.Close()



           MyConnection.Close()

           TextBox3.Text = TextBox3.Text & vbNewLine & "database closed"

       Catch myerror As MySqlException
           TextBox3.Text = "error"

       Finally
           If MyConnection.State <> ConnectionState.Closed Then MyConnection.Close()
       End Try

   End Sub

 

 

How am I suppose to compare the output to either true or null?

 

 

thanks

Lee

Posted

First of all you don't need a reader.

 

Dim myCmd As New OleDb.OleDbCommand("sp_ValidateLogin", MyConnection)
myCmd.CommandType = CommandType.StoredProcedure

if( myCmd.ExecuteScalar() == DBNull.Value)

 

This should do the trick, depending of the implementation of "sp_ValidateLogin"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...