|
-
May 10th, 2009, 12:29 PM
#1
Thread Starter
New Member
Memo field and Insert Into vb6 and mdb
Hi everyone.
I have a problem,have tried to find the solution,but it seams to miss it..
I'm using db created in MS Access 2003,and have a problem with memo field..
I'm beginner so forgive me if I'm doing something crazy,that's the way I so as best...This is the code..
1 Code:
strSQL = "INSERT INTO Table (ID, memoField1, memofield2) "
strSQL = strSQL & "VALUES (?, ?, ?)"
1 Code:
.Parameters.Append .CreateParameter("ID Number", adInteger, adParamInput, , inserter)
.Parameters.Append .CreateParameter("Memo1", adLongVarChar, adParamInput, 400, txtField1.Text)
.Parameters.Append .CreateParameter("Memo2", adLongVarChar, adParamInput, 500, txtField2.Text)
I have used "adVarChar" and "adLongVarWChar",and I need to be able to insert at least 500 characters into memo field...
The problem is that if I put 500,error occurs and it's also if I don't put anything...
As seen I'm using parameters,also ADO and mdb...
I am able to insert other data that is before this,and it's in the database so I have access to it and am able to insert just not in the memo field.
The error is next:
Run-time error '-2147217900 (80040e14)':
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
Before it was about missing parameters and then about incomplete info (without 500)..
I hope I gave enough of info s o You can help me.
Thank You for Your time and effort..
-
May 10th, 2009, 04:05 PM
#2
Re: Memo field and Insert Into vb6 and mdb
Is your table actually called Table? If so, change it to something else - as that is a reserved word, and using it causes errors like this one.
If that doesn't solve it, try using adVarChar for the memo fields, and just set the size to something large enough for your needs (perhaps 1000).
-
May 11th, 2009, 06:56 AM
#3
Thread Starter
New Member
Re: Memo field and Insert Into vb6 and mdb
Thank You for the replay.
No it's not called Table,I just wanted to avoid meaningless names (for others)...
Yes,I tried using adVarChar and got an error "invalid precision value"....
That's why I started using adLongVarChar...
Now I don't know if this may be the case,but just to be sure...
I'm using If statements,and after the first Insert Into is done I set do this
Code:
Set CatComm = Nothing
and before it starts with another Insert statement
Code:
Set CatComm = New ADODB.Command
There should be nothing wrong with SQL statements,I only receive errors on memo fields...
And I found on internet that adVarChar can store up to 250 characters?
Thank You.
-
May 11th, 2009, 09:46 AM
#4
Re: Memo field and Insert Into vb6 and mdb
 Originally Posted by BBBane
No it's not called Table,I just wanted to avoid meaningless names (for others)...
It's not a good idea to do that kind of thing - as we often find that problems are caused by something that has been hidden from us like that.
It is best to show us the actual code without edits, as the issue could well be something that you think is fine.
Yes,I tried using adVarChar and got an error "invalid precision value"....
That's why I started using adLongVarChar...
And I found on internet that adVarChar can store up to 250 characters?
Thank You.
That's an odd error, I don't think I've seen that for VarChar before.
The size limit is not based on ADO, but on the driver/provider you are using (SQL Server 2005 allows 8000 for adVarChar).
Now I don't know if this may be the case,but just to be sure...
I'm using If statements,and after the first Insert Into is done I set do this
Code:
Set CatComm = Nothing
and before it starts with another Insert statement
Code:
Set CatComm = New ADODB.Command
I'm afraid that amount of code is virtually meaningless, we can't tell anything from it - we'll need to see much more of it to be able to tell if there is something wrong.
-
May 18th, 2009, 06:05 AM
#5
Thread Starter
New Member
Re: Memo field and Insert Into vb6 and mdb
Thank You "si_the_geek".
I'm sorry,I wasn't able to come sooner,I resolved the problem by putting "[]" brackets around memo fields names... and used "LongVarChar" for parameter type.
Thank You for You're time and help.
PS: For the table names,I did that because I already had used those names in db and done search trough them and it had no error so I was more concentrated on the parameters as the problem,than that.
Last edited by BBBane; May 18th, 2009 at 06:09 AM.
Reason: Added the table names excuse...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|