Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Database & Reporting

Post new topic   Reply to topic
table creation with code and relations
View previous topic :: View next topic  
Author Message
albertsmus
Newbie


Joined: 24 Mar 2005
Posts: 1

PostPosted: Mar 24th, 2005 01:55 PM    Post subject: table creation with code and relations Reply with quote

i create an access table with the following code:

Dim oledbcommand As OleDb.OleDbCommand

oledbcommand = New OleDb.OleDbCommand
oledbcommand.Connection = cond
oledbcommand.CommandType = CommandType.Text
oledbcommand.CommandText = "create table customers(PtPelUnique autoincrement primary key,eponimo text(50),epagelma text(50),dieuthinsi text(50),poli text(25),tk text(5),tel text(15),email text(50),afm text(10),fax text(15),doi text(15),TelHome text(15),Mobile text(15),nomos text(15),Ptmemo memo) "

Try
oledbcommand.ExecuteNonQuery()

Catch ex As System.Data.OleDb.OleDbException

End Try

with similar code i create a table with name ptAgores (the fields are ptUnique autoincrement and PtPelunique )


now i try to create a relation between the two tables with the folowing lines of code:


oledbcommand = New OleDb.OleDbCommand
oledbcommand.Connection = cond
oledbcommand.CommandType = CommandType.Text
oledbcommand.CommandText = " ALTER TABLE ptAgores " & _
" ADD FOREIGN KEY PtPelunique TAG " & _
" PtPelunique REFERENCES customers"

Try
oledbcommand.ExecuteNonQuery()

Catch ex As System.Data.OleDb.OleDbException

End Try

i got an error here, in the commandtext. what am i doing wrong?
Thanks for any help.
Edit/Delete Message
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic