Home > Software engineering >  Vb insert into statement when a data type of yes/no data type mismatch
Vb insert into statement when a data type of yes/no data type mismatch

Time:09-17

The insert into statement is vb code: cmd.Com mandText="insert into order information table (order no., whether to arrange) values ('" & amp; Text1. Text & amp; "', '" & amp; Combo2. Text & amp; "')
"Which is arranged in the access Combo2 data type is also have chosen to y/n
But when fill in yes/no
Vb there will be a standard expression data type mismatch
Feeling statements have problems
Data types as text digital date is no problem about the Boolean type is not the same as

CodePudding user response:

This field in the database of the so-called "yes/no" is actually the Boolean fields
You must write the SQL statement true or false

CodePudding user response:

Then how to use yes/no alternative
true/false?Because I want to show in the table is a yes/no

CodePudding user response:

If your Combo2. In the Text content is' True 'or' False ', your SQL string enclosed in single quotes to remove it, single quotation marks are only suitable for character values,

The insert into statement is vb code: cmd.Com mandText="insert into order information table (order no., whether to arrange) values ('" & amp; Text1. Text & amp; "'," & amp; Combo2. Text & amp;
")"

CodePudding user response:

 s2=Replace (s1, "yes/no", "NULL") 
S3=Replace (s2, "yes", "True")
S4=Replace (s3, "no", "False")
If s4 & lt; & gt;" NULL "and s4 & lt; & gt;" True "and s4 & lt; & gt;" False "then debug. Print" Format error: "+ s1

CodePudding user response:

"Insert into order information table (order no., whether to arrange) values ('" & amp; Text1. Text & amp; "'," & amp; The iif (combo2. Text="yes", "1", "0") & amp;" )"
  • Related