Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

Declare SQL statement

$
0
0

Hi 

I have been changing my asp.net application from mssql to mysql due to client's request

This is the following codes that i have been changing and couldn't make it work due to this error

MSSQL : 

mySQL = "DECLARE @outputtbPollID TABLE (PollID CHAR(38)); INSERT INTO Poll (AddedDate, AddedBy, QuestionText, IsCurrent) OUTPUT INSERTED.PollID INTO @outputtbPollID VALUES(N'" + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + "', N'" + Session["UserID"] +"' , ?Question, '1'); SELECT PollID FROM @outputtbPollID;";

MySQL : 

I tried

mySQL = "BEGIN DECLARE outputtbPollID CHAR(38) END;" + "INSERT INTO Poll (AddedDate, AddedBy, QuestionText) OUTPUT INSERTED.PollID INTO @outputtbPollID VALUES(N'" + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + "', N'" + Session["UserID"] + "' , ?Question);" + "SELECT PollID FROM @outputtbPollID;";

OR

mySQL = "DECLARE outputtbPollID CHAR(38);select PollID from Poll;SELECT outputtbPollID;" + "INSERT INTO Poll (AddedDate, AddedBy, QuestionText) OUTPUT INSERTED.PollID INTO @outputtbPollID VALUES(N'" + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + "', N'"+ Session["UserID"] + "' , ?Question); " + "SELECT PollID FROM @outputtbPollID;";

but no result



Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>