Question Access database Query

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
I am trying to create an access database file with this query
VB.NET:
Expand Collapse Copy
   Dim oQuery As String = "CREATE TABLE " & table & _
                                " (Type TEXT(10) NOT NULL," & _
                                "Data TEXT(50) NOT NULL," & _
                                "Data2 TEXT(50) NOT NULL)"
then insert data into it with this query

VB.NET:
Expand Collapse Copy
        Dim oQuery As String = "insert into " & table & _
                                " values('" & type & _
                                "','" & data & _
                                "','" & data2 & "')"
That worked fine. But i want to add a primary key to it, how should i change my query? the create table one will be like this? insert data unchanged? but it doesnt seem to work right after i changed it

VB.NET:
Expand Collapse Copy
        Dim oQuery As String = "CREATE TABLE " & table & _
                                " (Type TEXT(10) NOT NULL," & _
                                "Data TEXT(50) NOT NULL," & _
                                "Data2 TEXT(50) NOT NULL," & _
                                "PRIMARY KEY(Type) )"
 
Last edited:
Try
VB.NET:
Expand Collapse Copy
Dim oQuery As String = "CREATE TABLE " & table & _
                                " (Type TEXT(10) PRIMARY KEY NOT NULL," & _
                                "Data TEXT(50) NOT NULL," & _
                                "Data2 TEXT(50) NOT NULL)"
 
Back
Top