| | |
query
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 39
Reputation:
Solved Threads: 0
sir i am developing application in windows so i want that when i serach data that data then that data is dislpayed indatagridview when i am doing that thecvdata is displayed but there is one blank row created in gridview below that row:means that suppose in first row of gridview tge serach data is there and below that an emnpty row is created .so how i block to create an empty row
i do search in keydown event
i do search in keydown event
•
•
Join Date: Dec 2008
Posts: 39
Reputation:
Solved Threads: 0
con = New OleDbConnection(constr) adpt = New OleDbDataAdapter("select * from drs_entry_list where drsno='" + DrsnoToolStripTextBox.Text + "' order by srno", con)
ds = New DataSet
adpt.Fill(ds)
If ds.Tables(0).Rows.Count - 1 >= 0 Then
For j As Integer = 0 To ds.Table0).Rows.Count - 1
Dim org As String = ds.Tables(0).Rows(j).Item(4) DataGridView1.Rows(DataGridView1.Rows(j).Cells(0).rowindex).Cells(5).Value = org.ToString
Dim AWBNO As Integer = ds.Tables(0).Rows(j).Item(1)
DataGridView1.Rows(DataGridView1.Rows(j).Cells(1).RowIndex).Cells(1).Value = AWBNO.ToString
Next
End If
End If
in this when i search through drsno the in datagridview it gives error :Index was out of range : i need that row is fetched and below it no empty row is created and when i press enter in any cell of datagridview a bove row ios copied as second row in datagridview
ds = New DataSet
adpt.Fill(ds)
If ds.Tables(0).Rows.Count - 1 >= 0 Then
For j As Integer = 0 To ds.Table0).Rows.Count - 1
Dim org As String = ds.Tables(0).Rows(j).Item(4) DataGridView1.Rows(DataGridView1.Rows(j).Cells(0).rowindex).Cells(5).Value = org.ToString
Dim AWBNO As Integer = ds.Tables(0).Rows(j).Item(1)
DataGridView1.Rows(DataGridView1.Rows(j).Cells(1).RowIndex).Cells(1).Value = AWBNO.ToString
Next
End If
End If
in this when i search through drsno the in datagridview it gives error :Index was out of range : i need that row is fetched and below it no empty row is created and when i press enter in any cell of datagridview a bove row ios copied as second row in datagridview
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
First, it's better to organize your code and make it readable 
Second, if no records has been found, the code If MyTable .Rows.Count - 1 >= 0 will raise an error because "Rows.Count = 0" and it cannot be decreased -1
Check if Rows.Count > 0

con = New OleDbConnection(constr)
adpt = New OleDbDataAdapter("select * from drs_entry_list where drsno='" + DrsnoToolStripTextBox.Text + "' order by srno", con)
ds = New DataSet
adpt.Fill(ds)
Dim MyTable as DataTable = ds.Tables(0)
If MyTable.Rows.Count - 1 >= 0 Then
etc etc etc.Second, if no records has been found, the code If MyTable .Rows.Count - 1 >= 0 will raise an error because "Rows.Count = 0" and it cannot be decreased -1
Check if Rows.Count > 0
Last edited by 4advanced; Apr 29th, 2009 at 4:31 am.
![]() |
Similar Threads
- Sql Query (VB.NET)
- Removing Query Strings (ASP.NET)
- Double MySQL Query (PHP)
- Dynamic Query (JSP)
- MySQL nested query / joined query conversion help (MySQL)
- problem with lengthy query (Java)
- Retreiving variables from a sql query into a form (PHP)
- Query Building (Database Design)
Other Threads in the VB.NET Forum
- Previous Thread: focus query
- Next Thread: Desktop Short cuts to application
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add arithmetic array assignment basic binary bing box button buttons center code combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists file-dialog firewall folder google hardcopy image images isnumericfuntioncall login math memory mobile module ms msaccess mssqlbackend mysql navigate net networking opacity output pan peertopeervideostreaming picturebox picturebox1 port print printpreview problemwithinstallation project record reports" reuse save savedialog serial sorting sqldatbase storedprocedure string temp text textbox timer toolbox updown useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf xml





