Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7983355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:56:08+00:00 2026-06-04T10:56:08+00:00

I am looking to make a database call based on user input. The line

  • 0

I am looking to make a database call based on user input. The line I am using is:

general_read.CommandText = "SELECT * FROM general WHERE Business_Name = '" & business_name & "';"

business_name is dynamically loaded from:

Protected Sub btnLoad_Click(sender As Object, e As System.EventArgs) Handles btnLoad.Click
    business_name = txtName.Text

    dbConnect()
    dbGet()
    dbDisconnect()
End Sub

The error that is being shown is:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

I’m assuming it has something to do with the variable not being set before the database call is made, but I’m not entirely sure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:56:09+00:00Added an answer on June 4, 2026 at 10:56 am

    I’m guessing it’s failing on

    general_read.CommandText = "SELECT * FROM general WHERE Business_Name = '" & business_name & "';"

    since this is the code you specified. If that’s the case, then you didn’t properly initialize the SQLCommand object. Below is the MSDN page that properly shows you how to use all of the overloaded constructors for the object.

    http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx

    If business_name is null, an exception will also be thrown when you try to concatenate your ComamndText string. Put a break-point on that line and see what is null. That’s where your problem lies.

    Hope this helps. If it’s not erroring on that line, please include the code where it does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the PDO Database Abstraction library to make sure my code is
I am looking to make a nice transition effect for a dynamic user layout
I'm trying to call a stored procedure from my MVC app using EntLib 5.0.
I am looking to make a small rpg game using php/mysql/javascript but I have
Im looking to make my own implementation of these Identicons or Gravatars found here
I'm looking to make a website that will probably get some heavy, repetitive traffic.
I'm looking to make a show action of one of my controllers the root.
We are looking to make a final decision on our Mocking framework. After trying
I'm looking to make an RPG with Cocos2D on the iPhone. I've done a
I am looking to make a horizontally layed website but I am having issues

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.