Wrox Programmer Forums
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2009, 09:19 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default Using the If Condition

Hi There,
I Need help with this

I have this code that populates a DataGrid in .Net 3.5 Win Forms works fine,
i need to add an if statment that if cmd returns >1 records Then windows2.show.

The idea is the if query returns more than 1 record a popup asks you wich one do you want to show, than you click the one you need and the datagrid populates with that record..

Code:
 
Dim cmd As SqlCommand = cnn.CreateCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT SLP05.CNAM05, SLP05.CUSN05, SLP05.CAD205, SimDefault.SimNet, SimDefault.Cost, SimDefault.Commission FROM SimDefault CROSS JOIN SLP05 Where (SLP05.CNAM05 Like '" & txtName.Text & "%')"Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = cmd
Dim ds As DataSet = New DataSet
da.Fill(ds, "CNAM05")
DataGridViewSearch.DataSource = ds
DataGridViewSearch.DataMember = "CNAM05"
__________________
bx
 
Old June 29th, 2009, 07:34 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default could you do...

could you just count the rows of the gridview?

Code:
If GridViewSearch.Rows.Count > 1 Then
  Windows2.Show()
End If
__________________
Jason Hall

Follow me on Twitter @jhall2013
 
Old June 30th, 2009, 02:34 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

Thanks 4 the reply, i could count the rows but the rows returned are not of a fixed number.

Most of the time the grid populates 13 rows of 1 customer with deferent field of sim , cost...
2 customers can have the same name but not same address, it would be ideal to check 4 postcode.
Something like Name Bill has 2 post codes than you check the 2 post codes are different than pop up the Windows2.Show()
__________________
bx





Similar Threads
Thread Thread Starter Forum Replies Last Post
or condition kgoldvas XSLT 1 July 31st, 2007 03:44 AM
where condition...? mnr555 Crystal Reports 0 June 18th, 2006 05:32 PM
String Condition ! anubandh ASP.NET 1.0 and 1.1 Basics 1 May 16th, 2006 01:15 AM
if then else condition mateenmohd Classic ASP Basics 0 April 16th, 2005 07:08 AM
Condition mateenmohd SQL Server 2000 6 May 6th, 2004 03:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.