I suppose that you are using MySQL Connector Net and you already have DataSet with TableAdaptor
select the adapter, press right mouse button and select Add/Query. SQL Statements/Insert query.
Append SELECT LAST_INSERT_ID() after the insert query, for example
INSERT INTO `ecrm_new`.`tblemail` (`userID`, `templateID`, `assignTO`, `assignTovalue`, `relatedTO`, `relatedTovalue`, `emailTO`, `emailCC`, `emailBC`, `subject`, `body`, `attach`, `status`, `html`, `CreatedDate`) VALUES (@userID, @templateID, @assignTO, @assignTovalue, @relatedTO, @relatedTovalue, @emailTO, @emailCC, @emailBC, @subject, @body, @attach, @status, @html, @CreatedDate);
SELECT LAST_INSERT_ID()
Finish the wizard and click the new created function. From the properties of the function select ExecuteMode = Scalar. Now you can use the function to insert the record and to get the id of the inserted record
long iID = (long)ttmail.InsertQuery(MailForm.LoggedRow.UserID,
null,
MailForm.LoggedRow.UserID,
2, 1, 1, tbTo.Text, "", "", tbSubject.Text, tbText.Text, 1, 1, 0, now);
Абонамент за:
Коментари за публикацията (Atom)
Няма коментари:
Публикуване на коментар