| |

VerySource

 Forgot password?
 Register
Search
View: 1337|Reply: 11

Isn't this code for creating tables wrong ???

[Copy link]

4

Threads

13

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-1-23 17:20:01
| Show all posts |Read mode
Private Sub Command1_Click ()
Dim conn2 As New ADODB.Connection
Dim sqlstring As String
Dim connectionstring As String
connectionstring = "provider = Microsoft.Jet.oledb.4.0; data source = default.mdb"
conn2.Open connectionstring
sqlstring = "create table aaa (a varchar (50), b number (10,3), c number (10,3))"
conn2.Execute sqlstring
'conn2.Execute "commit"

End Sub


Why is it always saying syntax error in creat table ???
What is wrong with this sqlstring?
Reply

Use magic Report

0

Threads

46

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-2-7 18:45:02
| Show all posts
Number is wrong.

create table aaa (a varchar (50), b money, c money)

This can replace
Reply

Use magic Report

4

Threads

13

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

 Author| Post time: 2020-2-7 20:30:01
| Show all posts
So if I have a date and it has a format, such as 2017-01-01, how can I get it?

I remember when I learned sql in oracle, number (10,3) was used like this ... Why not work here?

Thank you!
Reply

Use magic Report

0

Threads

46

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-2-7 22:00:02
| Show all posts
datetime
Reply

Use magic Report

0

Threads

46

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-2-7 22:30:01
| Show all posts
Or use the varchar type directly-the comparison and query conditions use the long date format, it is also possible.
Reply

Use magic Report

1

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-13 01:15:01
| Show all posts
create table #aaa (a varchar (50), b numeric (10,3), c numeric (10,3))

select *
from #aaa

Try it, there is no problem at all. numeric is correct. Ah
Reply

Use magic Report

1

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-13 06:45:01
| Show all posts
Also, if you encounter such a problem, you can copy the string to the query analyzer and try it, and it will report the error.
Reply

Use magic Report

0

Threads

46

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-2-14 21:15:01
| Show all posts
Access databases don't have a query analyzer, and Access doesn't support that many data types.

lz's connection string already stated
> provider = Microsoft.Jet.oledb.4.0; data source = default.mdb

Upstairs, such as mdb, still can not be executed.
create table aaa (a varchar (50), b numeric (10,3), c numeric (10,3))




Comparison or mapping of data types between Access databases and projects
http://www.hackhome.com/2005/1-15/20341716338.shtml
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-18 13:30:01
| Show all posts
create table aaa (a varchar (50), b numeric (10,3), c numeric (10,3))
2 data types do not exist in acess
should be
create table aaa (a string (50), b double, c double)
Reply

Use magic Report

1

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-21 14:00:01
| Show all posts
Sorry, I did not look carefully, it is access.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list