Avatar of DirkVerdonck
DirkVerdonck

asked on 

VB type mismatch error in powerdesigner- probably very simple

I have a problem with some visual basic code that has to be executed on a powerdesigner model.
If I execute this it gives me a "type mismatch" error on line 9  (first SQL)

this is probably something really stupid, but I'm not a VB programmer and I don't have a lot of time for this script, so any help would be very welcome.

dim sql_text
sql_text = ""
dim counter
counter = 0
for each tbl in mdl.tables
  for each fld in tbl.columns
    if (  fld.stereotype <> "" ) then
       counter = counter + 1
       sql_text = sql_text + "insert into database.fieldNames(id,name,tablename,datatype)" 
       sql_text = sql_text + "values (" + counter + "," + fld.Name + "," + tbl.Name + "," + fld.DataType + ")" + vbCrLf
    END IF
   next
next

Open in new window

Visual Basic ClassicSybase Database

Avatar of undefined
Last Comment
Jim Horn
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>insert into database.fieldNames
Normal syntax is database_name.table_name, assuming that's what the SQL is doing as opposed to an object named database with a property named fieldNames
Avatar of DirkVerdonck
DirkVerdonck

ASKER

the sql is not important for this question, it's the VB that gives me the error before outputting any generated sql.
it says :
runtime error
type mismatch : '[string: "insert into database.fie"]" (0x800A000D)

Open in new window

SOLUTION
Avatar of Gerry Bartley
Gerry Bartley
Flag of Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of DirkVerdonck
DirkVerdonck

ASKER

sorry for the delay, I've been on vacation for a few days. :-)
the concat with & doesn't solve it.
I've narrowed it down to the counter being added.  So the script must have a problem with converting the integer to a string automatically.
but I thought VB did this without a typecast?

finally solved the problem by putting

cstr(counter)

Open in new window


instead of just counter.

thanks for the help.
Avatar of DirkVerdonck
DirkVerdonck

ASKER

I think the question and the answers provide some information that might be helpful for someone else.
but the problem is I finally found the solution to the problem myself, I don't want to award myself points. :-)  and none of the other answers was completely correct.
so I didn't know what to do with it.
I'll let the moderators decide.. :)
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>I finally found the solution to the problem myself
I propose that since you've posted the solution, that the question be closed in a manner that does not award points (or awards reduced points to others that helped you, your call) so that others can benefit from your solution.
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo