trend Posted July 8, 2005 Posted July 8, 2005 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 Quote
FZelle Posted July 11, 2005 Posted July 11, 2005 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" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.