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

  • SEARCH
  • Home
  • 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 6800925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:02:01+00:00 2026-05-26T19:02:01+00:00

I have a textbox and a datagrid. I am trying to enter a last

  • 0

I have a textbox and a datagrid. I am trying to enter a last name into the textbox and have that return the entire record from that last name into the datagrid from an oracle database. The code below currently returns all records in the table and is not searching by the last name.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim myString As String
    Dim myArg As String
    Dim mysql As String
    Dim myConn As New OleDb.OleDbConnection()

    ' Create new connection
    myString = "Provider=msdaora;Data Source=XXXX;User Id=XXXX;Password=XXXX;"
    myConn.ConnectionString = myString
    myArg = TextBox1.Text
    mysql = "select * from table1 where lastname like '%'"
    Try
        myConn.Open()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try

    Dim myDataadapter As New OleDb.OleDbDataAdapter(mysql, myConn)

    Dim myDs As New DataSet

    myDataadapter.Fill(myDs, "customer")

    Dim prmLName As New OleDb.OleDbParameter()
    prmLName.Direction = ParameterDirection.Input
    prmLName.Size = "10"
    prmLName.Value = TextBox1.Text


    DataGridView1.DataSource = myDs
    DataGridView1.DataMember = "customer"
End Sub
End Class
  • 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-05-26T19:02:01+00:00Added an answer on May 26, 2026 at 7:02 pm

    You didn’t pass parameter value for the lastname , so Its taking it as a null and returning all the records :

    mysql = "select * from table1 where lastname like '%" 
    

    Here you would do like :-

     mysql = "select * from table1 where lastname like '%" & txtLastName.Text & "%'"  
    

    I will also suggest you to pass parameter by SqlCommand.Parameters Property to avoid SQL Injection.

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

Sidebar

Related Questions

I have a GroupBox that contains a stackpanel holding a textbox and a datagrid.
I do have a page that has a TextBox a Button and a Datagrid.
I have implemented a DataGrid that way: <DataGrid x:Name=MyDataGridFilter ItemsSource={Binding} IsSynchronizedWithCurrentItem=True AutoGenerateColumns=False> <DataGrid.Columns> <DataGridTemplateColumn
I'm working with textbox in a datagrid. Before saving the data into the database,
I have wpf datagrid with number of template columns. some of them have textbox
I have a datagrid and I added silverlight 4 toolkit contextmenu to textbox in
I have the control placed in DataGrid like this: <Label Name=lblDescription HorizontalAlignment=Left Margin=0,5,0,0 Grid.Row=2
I have a Silverlight app, with a dataGrid in it, I added a TextBox
I have a SL DataGrid that has two columns. I need to be able
I am using the PagedCollectionView for grouping. I have a DataGrid and a textbox

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.