Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch

Status
Not open for further replies.

JCooL

Programmer
Oct 21, 2001
89
US
Hi there...

Code:
StrConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Applications;Data Source=SERVER4"

conn.Open StrConn

sql = "insert into ImportHead (PERIOD)"
sql = sql & "'" & txtPeriod.Text & "')"

set rs = conn.execute(sql) 'Here the error

the field type is Char - 30

Thanks in Advance



 
It always helps me to look at the query string by using a message box or writing it to a file if it is too long.

Unless you left something out I am guessing your query might look like this:
Code:
insert into ImportHead (PERIOD) 'sometext')
I don't know what rdbms you are using but a normal insert looks like:
Code:
insert into ImportHead (PERIOD) values ('sometext')
If that is not the problem and you just left out some code- what is the exact error message- type of database server- content of text box, etc.
 
Your insert should look like this,

sql = "insert into ImportHead (PERIOD) Values ('" & txtPeriod.Text & "')"
Thanks and Good Luck!

zemp
 
Thanks guys,

i did it, and make the same.

from Visual Basic i made this,

sql = "insert into ImportHead (PERIOD) Values ('01/03')

when i execute this in SQLServer Query Analyser work fine, but from Vbasic genereted the error and save the data.

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top