473,396 Members | 2,010 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,396 software developers and data experts.

data mismatch in critical expression

Expand|Select|Wrap|Line Numbers
  1. Private Sub DataGridView1_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
  2.         Try
  3.             Dim dt As New DataTable
  4.             'Dim dr As DataRow
  5.          dp = "Provider=Microsoft.Jet.OLEDB.4.0;"
  6.         src = "Data source=c:\Database\licdb.mdb"
  7.             con.ConnectionString = dp & src
  8.             con.Open()
  9.             'db()
  10.             query = "select * from year2008 where id = '" & id & "'"
  11.             da = New OleDb.OleDbDataAdapter(query, con)
  12.             da.Fill(ds1, "tab")
  13.             da.Fill(dt)
  14.  
  15.             TextBox1.Text = ds1.Tables("tab").Rows(id).Item(1).ToString()
  16.             TextBox2.Text = ds1.Tables("tab").Rows(id).Item(2).ToString()
  17.             TextBox3.Text = ds1.Tables("tab").Rows(id).Item(3).ToString()
  18.             TextBox4.Text = ds1.Tables("tab").Rows(id).Item(4).ToString()
  19.             TextBox5.Text = ds1.Tables("tab").Rows(id).Item(5).ToString()
  20.             TextBox14.Text = ds1.Tables("tab").Rows(id).Item(6).ToString()
  21.             TextBox7.Text = ds1.Tables("tab").Rows(id).Item(7).ToString()
  22.             TextBox8.Text = ds1.Tables("tab").Rows(id).Item(8).ToString()
  23.             TextBox9.Text = ds1.Tables("tab").Rows(id).Item(9).ToString()
  24.             TextBox10.Text = ds1.Tables("tab").Rows(id).Item(10).ToString()
  25.             TextBox16.Text = ds1.Tables("tab").Rows(id).Item(11).ToString()
  26.             TextBox11.Text = ds1.Tables("tab").Rows(id).Item(12).ToString()
  27.             TextBox17.Text = ds1.Tables("tab").Rows(id).Item(13).ToString()
  28.             con.Close()
  29.         Catch ex As Exception
  30.             MsgBox(ex.Message, MsgBoxStyle.Critical)
  31.             Me.Close()
  32.         End Try
  33.  
  34.     End Sub
Oct 26 '13 #1
1 1294
Luuk
1,047 Expert 1GB
When you do this:
query = "select * from ......

You will never KNOW how much columns will be returned from the database, you should therefore use the proper columnnames, and not '*'
query = "select column1, column2, .... from .....
Oct 26 '13 #2

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

Similar topics

3
by: heresjonny | last post by:
Could anyone shed any light on this error message i keep getting when i try to open a report outside of design view, "mismatch in expression". I have created the report using the wizard, and...
1
by: Maika | last post by:
lstSearchDoctor.ItemData(lstSearchDoctor.NewIndex) = mrsDoctorList!DoctorCode Where DoctorCode as String lstSearchPatient.ItemData(lstSearchPatient.NewIndex) = mrsPatientList!PatientNum ...
2
by: rellaboyina | last post by:
Hi, I am a newbie to this forum and I want some help from you. I want to extract some data using jdbc by connecting to the Ms-Access database. When I tried to extract the data from two tables...
2
by: irkahs | last post by:
Dear friends, I am connecting an ASP page to an Access table. The table in Access has a field called orderNo which is of type "Number". Now...what I want to do is design an SQL...
1
by: =?Utf-8?B?S3VtYXIuQS5QLlA=?= | last post by:
I am having a problem in reading the values from the excel sheet in ASP .Net. I am using the following connection string to read values from rows from an excel sheet into a dataset. One of the...
2
by: tmoon3 | last post by:
Hello, This must be a simple mistake, but for some reason I cannot seem to get around it. I am simply trying to create a report of all employees that have a date filled in in a training column...
9
by: pavanponnapalli | last post by:
hi, i have data as under. 127.0.0.1 - - "GET /favicon.ico HTTP/1.1" 404 292 127.0.0.1 - - "GET /favicon.ico HTTP/1.1" 404 292 127.0.0.1 - - "GET /pear/symfony/ HTTP/1.1" 404 294...
2
by: kwokv616 | last post by:
=( what is wrong with this... when i run the query it says "data type mismatch in criteria expression"... Field aprid: Sum((++)*1*IIf((Not (=) And Not (=("TOPUP" Or "FSB" Or "FSSB" Or "MKB")))...
10
by: rouny4u | last post by:
Hello, I started working on VBA,access from yesterday, and here I am with my first problem :). Please help. I get the above mentioned problem when my UDF is returning an integer.(Following is...
10
by: Qtip23 | last post by:
I am having trouble getting my SQL string to operate correctly. I have modified an online application for my use but I think because the fields were all text. I continuously receive an Error 13:...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.