473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Object reference not set to an instance of an object.

I need your kind help.
I am basically wanting to filter the data from SQL server database via VB.NET combo box to data grid view, make changes and then save them back to the database.

The thing is i am not being able to filter the data via the combobox

Expand|Select|Wrap|Line Numbers
  1. "Imports System.Data
  2. Imports System.Console
  3. Imports System.Data.SqlClient
  4. Imports System.Data.OleDb
  5.  
  6. Public Class Form1
  7.  
  8.     Dim sqlcon As New SqlConnection
  9.     Dim ds As New DataSet
  10.     Dim dc As SqlCommand
  11.     Dim daa As New SqlDataAdapter
  12.     Dim bs As New BindingSource
  13.     'Public Const ConnectionString As String = "Data Source=SQLORACLE;Initial Catalog=greeting;User ID=classic;password=stripes"
  14.  
  15.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  16.         'TODO: This line of code loads data into the 'GreetingDataSet.db1' table. You can move, or remove it, as needed.
  17.  
  18.         Me.Db1TableAdapter.Fill(Me.GreetingDataSet.db1)
  19.         cboest.Sorted = True
  20.         cboest.Enabled = False
  21.         cbover.Enabled = False
  22.         Db1DataGridView.Visible = False
  23.         Db1BindingNavigator.Visible = False
  24.     End Sub
  25.  
  26.     Private Sub Db1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Db1BindingNavigatorSaveItem.Click
  27.         Me.Validate()
  28.         Me.Db1BindingSource.EndEdit()
  29.         Me.Db1TableAdapter.Update(Me.GreetingDataSet.db1)
  30.     End Sub
  31.  
  32.     Private Sub cmdselect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdselect.Click
  33.  
  34. // filtering the according to "estno"
  35.  
  36.  
  37.         Dim cbostr
  38.         cbostr = Me.cboest.Text
  39.         Dim dv As DataView
  40.         dv = ds.Tables("db1").DefaultView
  41.         dv.RowFilter = "estno like = " & cbostr
  42.         cboest.Enabled = True
  43.         cmdselect.Enabled = False
  44.     End Sub
  45.  
  46.     Private Sub cboest_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboest.SelectedIndexChanged
  47.  
  48.         cbover.Enabled = True
  49.     End Sub
  50.  
  51.     Private Sub cbover_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbover.SelectedIndexChanged
  52.         cboest.Enabled = False
  53.         cbover.Enabled = False
  54.         cmdselect.Enabled = True
  55.         Db1DataGridView.Visible = True
  56.         Db1BindingNavigator.Visible = True
  57.     End Sub
  58. End Class"

My code may be wrong or mistaken, for which I need your help.
Please reply
Jan 18 '11 #1
2 957
try changing lline 41 to use % filters. In SQL the way you have have coded the 'like' it would act like'='.
Expand|Select|Wrap|Line Numbers
  1. dv.RowFilter = "estno like = %" & cbostr & "%"
Jan 19 '11 #2
Thanks a lot
it's working.
Jan 19 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server...
6
by: NewToDotNet | last post by:
I am getting "Object reference not set to an instance of an object. " when I attempt to open a C# windows service class in design view, although I was able to initially create the service and open...
4
by: Frawls | last post by:
Hi, I get the following error when trying to run a search on my aspx site, this error only occours if the product im searching for does not exist. Can anybody explain this please and help me...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
2
by: jw56578 | last post by:
why am i getting the "Object reference not set to an instance of an object" error on all page registeration tags in my project. <%@ Page Language="vb" AutoEventWireup="false"...
3
by: nemo | last post by:
Hi, My application works fine on the localhost but spits this error as soon as I put it on the server. I know this error occurs when an object has not been instantiated prior to a reference, but...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
6
by: kalaivanan | last post by:
hi, i am a beginner in c#. i have theoretical knowledge about object, reference and instance. but i want to know clearly about what is an object, reference and instance. can any one help me? or...
1
by: vishnu | last post by:
Hi, I am working on asp.net project which I converted the code fron VB to C# and instead of RaiseEvent in VB code I used the following code. using System; using System.Data; using...
4
by: livmacca | last post by:
Hi, I am new to VB .Net programming and is trying to create a webpage. I encountered the following error and is totally clueless on how to make it work: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.