Try this one.
Rgds/ Renga
Dim strQry, sValuer, sValuerMail As String
Dim SqlCmd As New SqlCommand
Dim dtr As SqlDataReader
strQry ="select Fullname, EMail from TM_users where UsersId=" &
cmbValuer.SelectedValue
Try
If conDB.State = ConnectionState.Closed Then conDB.Open()
SqlCmd = New SqlCommand(strQry, conDB)
dtr = SqlCmd.ExecuteReader(CommandBehavior.CloseConnection)
dtr.Read()
If Not dtr.HasRows Then
MsgBox("Sorry No Relevant details for this valuer !",
MsgBoxStyle.Critical, "Failure")
Else
If Not IsDBNull(dtr("FullName")) Then sValuer = dtr("FullName")
If Not IsDBNull(dtr("EMail")) Then sValuerMail = dtr("EMail")
End If
Catch ex As Exception
MsgBox(ex.Message)
SqlCmd.Dispose()
conDB.Close()
dtr.Close()
Exit Sub
End Try
SqlCmd.Dispose()
conDB.Close()
dtr.Close()
Dwayne Hope <[EMAIL PROTECTED]> wrote:execute non-query returns the number of
rows affected by the non-query statement ie the number of rows updated,
inserted or deleted. You need execute scalar for one row or execute reader for
multiple rows. You'll have to follow that with a reader.read() to cycle the
rows or hasrows to check for rows returned.
HTH
Dwayne
Michael Swanson <[EMAIL PROTECTED]> wrote:
Hi,
Yes, I have checked the Query Analizer and the stored procedure
returns the results I am looking for. I can also change my code
somewhat to use a data adapter with a dataset and use the query that
I have been using as the data adapters select command. I can fill
the dataset and show my results in a datagrid. However when I am
just using a straight sqlcommand to set up the query as normal, open
the connection, run the query, then close the connection, I keep
getting back a -1. I can not understand what is happening that will
make it not return the expected results. Once again for you to
view, here is the low down of the command:
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlConnection1;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@CName", SqlDbType.VarChar,
50));
cmd.Parameters["@CName"].Value = txtNewCharName.Text;
cmd.CommandText = "spCheckIfCharExists";
sqlConnection1.Open();
lblRegister.Text = cmd.ExecuteNonQuery().ToString();
sqlConnection1.Close();
If anyone could please help me figure out what is happening I would
truely appreciate it. Thank you!
Yahoo! Groups Links
[Non-text portions of this message have been removed]
SPONSORED LINKS
Basic programming language Computer programming languages Programming languages
Java programming language The history of computer programming language
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/