473,657 Members | 2,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error 3421: "Data Type Conversion Error.

25 New Member
Hi Guys

Season greetings to everyone.

Does anyone have an idea to this error message.

Thanks
gilsygirl
Dec 17 '07 #1
10 4978
debasisdas
8,127 Recognized Expert Expert
that simply means the target variable and the content does not match.
Dec 17 '07 #2
gilsygirl
25 New Member
that simply means the target variable and the content does not match.
Hi thanks for the reply. how do i treat a text variable define as string. cos that is all i have done. but the error keeps coming from my sql statement.
Is there any other suggestion u have.

thanks
Dec 24 '07 #3
debasisdas
8,127 Recognized Expert Expert
Hi thanks for the reply. how do i treat a text variable define as string. cos that is all i have done. but the error keeps coming from my sql statement.
Is there any other suggestion u have.

thanks
Kindly post what exactly youare trying to do and also the SQL statment that you are trying to execute.
Dec 24 '07 #4
Killer42
8,435 Recognized Expert Expert
Ignore me. I'm just registering an interest in this thread so I can tell when new messages are posted.
Dec 24 '07 #5
gilsygirl
25 New Member
Kindly post what exactly youare trying to do and also the SQL statment that you are trying to execute.
Thanks for the reply

I am trying to extra a record from a database using a combination of 3 of the fields in the database as a key. So i am querying them in an Sqlstmt variable use as the recordset. the fields in the database are define as text and in the vb form the variable agruments are define as string.

So when i enter the variables on the form a second form should load displaying a record base on the variables passed provided it is in the database.

this my code

Expand|Select|Wrap|Line Numbers
  1. Public Function initdb()
  2. On Error GoTo error
  3. Set ws = DBEngine.Workspaces(0)
  4. Set db = ws.OpenDatabase("c:\resultchecker.mdb")
  5. Set rs = db.OpenRecordset("candres", dbOpenTable, dbReadOnly)
  6. Set rs1 = db.OpenRecordset("subject", dbOpenTable, dbReadOnly)
  7.  
  8. Exit Function
  9. End Function
  10.  
  11. Sub cmdCheck_click()
  12.  
  13. Dim Exam_Sr As String
  14. Dim Exam_Yr As String
  15. Dim Cand_No As String
  16. Dim CentNo As String
  17.  
  18. If rs.RecordCount = 0 Then Exit Sub
  19.    rs.MoveFirst
  20. For i = 1 To rs.RecordCount ' Read all the records from database
  21.  
  22. sqlStmt = "select * From candres where ExamSeries='" & Exam_Sr & "'and ExamYear='" & Exam_Yr & "'and CentNo='" & Cand_No & "'"
  23.     rs.OpenRecordset sqlStmt, db
  24.  
  25. If Not (rs.EOF) Then
  26.        frmCandResult.Show vbModal, Me
  27.     Else
  28.         MsgBox "sorry not a perfect match"
  29.     End If
  30.  
  31. CentNo = rs("CentNo")
  32. Cand_No = rs("IndexNo")
  33. Sex = rs("Sex")   
  34.  
  35.  frmListing.Cent_No.Caption = rs("CentNo")
  36.    frmListing.Cand_No.Caption = rs("IndexNo")
  37.    frmListing.Cnd_Name.Caption = rs("CandName")
  38.  
  39.     frmListing.Show vbModal, Me
  40.        rs.MoveNext
  41.        Next i
  42. End Sub
Dec 27 '07 #6
debasisdas
8,127 Recognized Expert Expert
1. Which line of code is creating the error ?
2. Why using a function with out any out type and nothing to return ?
3. Why opening the same recordset twice from two different sources ?
4. You have never called the function in the click event.
5. Try to use ADO code , that is much more flexible.
Dec 27 '07 #7
Killer42
8,435 Recognized Expert Expert
My guess is that the CentNo field is numeric. If you have a close look at line 22 of the code, you'll see that it is being compared to variable Cand_No, delimited by quotes. This may be the source of the problem.
Dec 27 '07 #8
gilsygirl
25 New Member
1. Which line of code is creating the error ?
2. Why using a function with out any out type and nothing to return ?
3. Why opening the same recordset twice from two different sources ?
4. You have never called the function in the click event.
5. Try to use ADO code , that is much more flexible.
Thanks for the reply. I have been able to solve the query. I was passing the values to a different form then the required form. The new query is in the SQL statement. It is only picking the first record in the database.

Now I want to know which function you are referring to and where I am opening the recordset twice.
Thanks for the help, really appreciated.
gilsygirl newbie
Jan 2 '08 #9
gilsygirl
25 New Member
My guess is that the CentNo field is numeric. If you have a close look at line 22 of the code, you'll see that it is being compared to variable Cand_No, delimited by quotes. This may be the source of the problem.
Thanks for the reply. I have been able to solve the query. My latest problem is the SQL statement. It is only picking the first record from the database.

This is the code:
Expand|Select|Wrap|Line Numbers
  1. If rs.RecordCount = 0 Then Exit Sub
  2. rs.MoveFirst
  3. For i = 1 To rs.RecordCount ' Read all the records from database
  4.  
  5.   sqlStmt = "select * From candres where ExamSeries='" & Exam_Sr & "'and ExamYear='" & Exam_Yr & "'and CentNo='" & Cand_No & "'"
  6.   rs.OpenRecordset , sqlStmt
  7.  
  8.   If Not (rs.EOF) Then
  9.     Call dispres
  10.     ' frmListing.Show vbModal, Me
  11.   Else
  12.      MsgBox "sorry not a perfect match"
  13.   End If
  14.  
What is wrong with this code?

Thanks for help it's really appreciated.
gilsygirl newbie
Jan 2 '08 #10

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

Similar topics

3
4691
by: 21novembre | last post by:
Hi all, I made a question several days before to describe my strange trouble of mysqldump. But I still can't figour it out. Well, I just want to ask another question whether I could just backup my databases by copying the data folder to some place? Then if I meet some disaster, could I just copy the backup folder back to recover my databases? Thank you. Zh.y
1
1519
by: Esben Rune Hansen | last post by:
Hi I am working on a PHP-script and need javascript to set the value of a hidden field in a form. This field happens to be an entry in an array data according to my example. How can I do this? Below is listet two PHP-pages: one that doesn't work (to my dismay), and another that does work, but do not use an array entry in the hidden field. Thanks
6
5244
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> My question is how do I access the document DOM of this object in Javascript? For example, "alert(extendedhtml.innerHTML);" doesn't work and produces an unknown error. I'd like to both read and write to the document's body element's innerHTML...
0
1653
by: John Smith | last post by:
Hi I am getting the above error when I try to run the union query shown below select all as , as , as , as , ,, ,, , , as , as , as , as , as from
4
25241
by: Saso Zagoranski | last post by:
Hi! I have created an SqlCommand object and I have set some parameters to it... One of the parameters is of the DateTime type; here is the code: sqlCommand.Parameters.Value = DateTime.Parse(this.DateTextBox.Text); sqlCommand.ExecuteNonReader(); I get the error:
11
5641
by: sofeng | last post by:
I'm not sure if "data hiding" is the correct term, but I'm trying to emulate this object-oriented technique. I know C++ probably provides much more than my example, but I'd just like some feedback to find out if I've done anything wrong. Also, I am working on this for an embedded environment, so if there are great inefficiencies with this code, I'd like to know that also. I realize there is overhead with using an "accessor" function. ...
8
1633
by: mdh | last post by:
May I ask this. Given the declaration: int myf( int, int); and a function pointer: (*fp)=int myf(int, int); where I am initializing fp to point at myf....or trying to..
3
12542
by: eros | last post by:
ALTER TABLE public.postcodes ALTER COLUMN machi TYPE varchar(100); Error: ERROR: syntax error at or near "TYPE"; Error while executing the query (State:42601, Native Code: 7) I am using WinSQL, Windows XP SP2 Japanese Version, PostgreSQL 8.x. I want to alter my machi field from varchar(30) to varchar(100) TYPE. This is my CREATE TABLE script:
18
2448
by: Stephan Beal | last post by:
Hi, all! Before i ask my question, i want to clarify that my question is not about the code i will show, but about what the C Standard says should happen. A week or so ago it occurred to me that one can implement a very basic form of subclassing in C (the gurus certainly already know this, but it was news to me). What i've done (shown below) seems to work all fine and well, and does exactly what i'd expect, but i'm asking about
0
8392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.