Hi, Im new to mysql and need some help.
I have a .Net app, using the .Net Mysql Connector.
I have created a table something like this:
"Create Table tblName" +
"(PK_thisTable int Not Null Auto_Increment," +
"PRIMARY KEY(PK_thisTable)," +
"Name varchar(30) not null," +
"Description varchar(255)," +
"CreateDate datetime," +
"ClosedDate datetime," +
"AccruedMinutes float, " +
"ModifiedDate datetime)"
I populate the table thru the .Net Connector something like this:
"Insert into tblName " +
"(Name,Description,CreateDate) values " +
"('" + sName + "','" + sDesc + "','" + MySQLDateTime(dt) + "');";
This works just fine, my problem is that I need the PK it created. I have tried to retrieve it using this:
"Select LAST_INSERT_ID();"
which gives me nothing. When I run it in Mysql Admin command prompt, I get a '0' for every row I have inserted. When I look at the table thru a select query, I see that each row has a unique number for the primary key.
What am I doing wrong, how can i get the last inserted primary key?
BTW: mysql_insert_id() returns a syntax error.
Thanks
I have a .Net app, using the .Net Mysql Connector.
I have created a table something like this:
"Create Table tblName" +
"(PK_thisTable int Not Null Auto_Increment," +
"PRIMARY KEY(PK_thisTable)," +
"Name varchar(30) not null," +
"Description varchar(255)," +
"CreateDate datetime," +
"ClosedDate datetime," +
"AccruedMinutes float, " +
"ModifiedDate datetime)"
I populate the table thru the .Net Connector something like this:
"Insert into tblName " +
"(Name,Description,CreateDate) values " +
"('" + sName + "','" + sDesc + "','" + MySQLDateTime(dt) + "');";
This works just fine, my problem is that I need the PK it created. I have tried to retrieve it using this:
"Select LAST_INSERT_ID();"
which gives me nothing. When I run it in Mysql Admin command prompt, I get a '0' for every row I have inserted. When I look at the table thru a select query, I see that each row has a unique number for the primary key.
What am I doing wrong, how can i get the last inserted primary key?
BTW: mysql_insert_id() returns a syntax error.
Thanks