Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I determine if nothing is returned

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
When I use this statement

Dim selectCMD2 As SqlCommand = New SqlCommand()
selectCMD2.CommandText = &quot;Select * from timemonths where loginID = '&quot; & Session(&quot;whosonline&quot;) & &quot;' and monthnumber < '&quot; & today & &quot;' and approval = '0'&quot;
selectCMD2.Connection = dbconn
selectCMD2.CommandTimeout = 30
dbconn.open
showmonth.DataSource = selectCMD2.ExecuteReader()
showmonth.DataBind()
dbconn.close()

How can I detiremine if nothing was stored in the showmonth. I tried using

if selectCMD.ExecuteNonQuery() = 0 then

But this doesn't seem to work, Any suggestions would be great???
 
for your sql command you could try this


If exists &quot;Select * from timemonths where loginID = '&quot; & Session(&quot;whosonline&quot;) & &quot;' and monthnumber < '&quot; & today & &quot;' and approval = '0'&quot;
&quot;Select * from timemonths where loginID = '&quot; & Session(&quot;whosonline&quot;) & &quot;' and monthnumber < '&quot; & today & &quot;' and approval = '0'&quot;
That'l do donkey, that'l do
[bravo] Mark
 
That would be changing my select statement right? I need to know if there is a value that is returned so I can show or hide a panel. So how would I detiremine this so I can either show or hide my panel? How could I make this into an if statement

if data is present then
show panel code
end if
 
Paul (link9) provided this tid bit the other day:

If IsDBNull(Value) Then
it's null
Else
it's not null
End If
 
Question:What is ShowMonth (the control that you're binding and setting the datasource).

You may not need to check for Null values at all. For instance, lets assume its a datagrid.

Now, you're binding the grid to whatever comes back from teh sql, right? So all you'd need to do is

If dgShowMonth.items.count > 0 Then
Panel.Visible = True
Else
Panel.Visible = False
End If

you don't have to evaluate for Null at all.

Jack
 
This is how we approach the problem:

Dim conn as SQLConnection
Dim SQL as SQLCommand
Dim selectCMD2 as SQLDataReader
Dim SQLserver AS String = &quot;server='MyServer'; user id='MyID'; password='MyPassword'; Database='MyDatabase'&quot;
Dim ds AS New DataSet

conn = new SQLConnection(SQLServer)
SQL = new SqlCommand(&quot;Select * from timemonths where loginID = '&quot; & Session(&quot;whosonline&quot;) & &quot;' and monthnumber < '&quot; & today & &quot;' and approval = '0'&quot;, conn)
conn.Open()

selectCMD2 = MySqlCommand.ExecuteReader()

' Determine if it is null by
if (selectCMD2.Read()) then
' use dataset
else
' processing for no records returned
end if

-----------------------------------------
Seems to work fine

Nuke
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top