473,395 Members | 1,730 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.

Select * from tablename where ID = '"& textbox1.text & "'

i will input a number in textbox1 which will be the id column in the database and then when i press the search button it will display the corresponding data based on the id. here's my code

Expand|Select|Wrap|Line Numbers
  1.  strsql = "select * from tbuser where ID = '" & TextBox1.Text & "'"
  2.         sqlcmd.CommandText = strsql
  3.         sqlcmd.Connection = GetConnection1()
  4.         read = sqlcmd.ExecuteReader()
  5.  
  6.         If read.HasRows Then
  7.             While read.Read
  8.  
  9.                 Label2.Text = (read.GetChar(1))
  10.             End While
  11.         End If
  12.         GetConnection1.Close()
  13.  
the error is in
Expand|Select|Wrap|Line Numbers
  1. read = sqlcmd.ExecuteReader()
  2.  
Data type mismatch in criteria expression.
i use ms access for the database and visual studio 2010.
thanks in advance for helping ^_^
Mar 6 '13 #1
3 9075
Rabbit
12,516 Expert Mod 8TB
What is the SQL string that is executed (with the variables expanded)?

What is the design of the table?

What is the data type of the read variable?
Mar 6 '13 #2
Mikkeee
94 64KB
Generally an ID column in your database will be a numeric data type but you're passing it along as a string by enclosing your sql in single quotes.
Mar 7 '13 #3
Expand|Select|Wrap|Line Numbers
  1. vbcon.Open()
  2.             Dim str As String = ""
  3.  
  4.             str = "SELECT * FROM mytablename"
  5.  
  6.  
  7. Dim dbCommand As New SqlCommand(str, vbcon)
  8. Dim dbReader = dbCommand.ExecuteReader
  9.  
  10.  
  11.  While dbReader.Read()
  12.                 textboxtext = dbReader.Item("myvarname")
  13.  End While
  14.             dbReader.Close()
Jun 14 '13 #4

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

Similar topics

2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
3
by: Steve Lutz | last post by:
Hi All, I have a Windows Service that runs well. The service hosts a remote object. The purpose of the object is so that I can "peak" into the service to see what it's doing. I wrote a small...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
3
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn...
7
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, I need to check if a textbox (of size = 1) contains a specific value (character). I could say something like If txt1.text.equals("X") or txt1.text.equals("Y")... then... Ideally, I...
2
by: pagoto123 | last post by:
select * from table where director = '" & Director.text & "' i want to display me all results that start with the director that the user will enter........ please i need the command help me...
2
by: kilo | last post by:
Hey.. I need someone hwo can help me making my sql table.. I have no php skills. I have payed for a php program that shoud make dictation for people that have some problems reading danish.. with...
5
by: Tony Toews [MVP] | last post by:
I'm very upset with Google's policy of indexing and allowing Google advertising on forum web sites which are "slurping" content from Usenet and Microsoft newsgroup servers. ...
1
by: =?Utf-8?B?VGFsYWxTYWxlZW0=?= | last post by:
i have facility in my website which sends an e-mail to the cleint's inbox..... i am getting a problem when ever i sends an e-mail.. i tried with Hotmail and Yahoo, e-mail goes to the "Junk Mail"...
0
by: Breyten | last post by:
Hi guys Any help would greatly be appreciated I've got a small application that needs to convert a string "textbox1.text" to textbox1.text So dim number1 as string = "textbox1.text"...
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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.