Resolved make the field a text field

Runescope

Well-known member
Joined
Jan 6, 2011
Messages
53
Programming Experience
Beginner
I added this into my code:

    dbCMD = New OleDbCommand("ALTER TABLE [RegTable] ALTER COLUMN [RenewDate] Text", Conn)
    dbCMD.ExecuteNonQuery()
    dbCMD = New OleDbCommand("ALTER TABLE [RegTable] ADD PRIMARY KEY(RenewDate)", Conn)
    dbCMD.ExecuteNonQuery()


It successfully makes the field 'RenewDate' the primary key, but it DOESN'T make the field a text field, which is necessary apparently as it started off as a Memo field, and Memo fields can't be primary keys for some reason. At least my program keeps crashing as long as it's still a memo field.

Sooooooo, now I need to figure out how to change the primary column to a Text field instead of a Memo field. Or am I just doing this in the wrong order? Change to primary and then to text?
 
Last edited:
AHA! I tracked down the culprit. :) I had to put a length after the 'Text'. So the line would be:

dbCMD = New OleDbCommand("ALTER TABLE [RegTable] ALTER COLUMN [RenewDate] Text(20)", Conn)


It's the simplest things I overlook sometimes. :blush:
 
Back
Top