albertsmus
03-24-2005, 02:32 AM
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.
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.