アプリケーションをMSSQLからMYSQLに切り替える処理中です。asp.netとSqlDataSourceコントロールのMySQL出力パラメータ
:私はMSSQLを使用していたとき、私は私がYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0 = LAST_INSERT_ID()' at line 1
InsertCommand="INSERT INTO LotManager_impounds (accountId, truckId, createdBy, driver, locationId, dateArrived, towedFrom, reasonForImpound, reasonForImpoundOther, impoundCity, impoundCounty, timeOfImpound, dateDeemedAbandoned, ticketNumber) VALUES (@accountId,@truckId,@createdBy,@driver,@locationId,@dateArrived,@towedFrom,@reasonForImpound,@reasonForImpoundOther,@impoundCity,@impoundCounty,@timeOfImpound,@dateDeemedAbandoned,@ticketNumber); SET @impoundId = LAST_INSERT_ID();"
をしようとすると、今、私はエラーを取得
Private Sub dsImpoundInformation_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles dsImpoundInformation.Inserted
_impoundId = e.Command.Parameters("impoundId").Value
End Sub
Private Sub dsImpoundInformation_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsImpoundInformation.Inserting
Dim impoundIdparam As New SqlClient.SqlParameter()
impoundIdparam.ParameterName = "impoundId"
impoundIdparam.Direction = System.Data.ParameterDirection.Output
impoundIdparam.DbType = DbType.Int32
impoundIdparam.Value = 0
e.Command.Parameters.Add(impoundIdparam)
End Sub
と
InsertCommand="INSERT INTO LotManager_impounds (accountId, truckId, createdBy, driver, locationId, dateArrived, towedFrom, reasonForImpound, reasonForImpoundOther, impoundCity, impoundCounty, timeOfImpound, dateDeemedAbandoned, ticketNumber) VALUES (@accountId,@truckId,@createdBy,@driver,@locationId,@dateArrived,@towedFrom,@reasonForImpound,@reasonForImpoundOther,@impoundCity,@impoundCounty,@timeOfImpound,@dateDeemedAbandoned,@ticketNumber); SET @impoundId = SCOPE_IDENTITY();"
を経て、最後の自動インクリメント値を取得し
と私が試したとき:
InsertCommand="INSERT INTO LotManager_impounds (accountId, truckId, createdBy, driver, locationId, dateArrived, towedFrom, reasonForImpound, reasonForImpoundOther, impoundCity, impoundCounty, timeOfImpound, dateDeemedAbandoned, ticketNumber) VALUES (@accountId,@truckId,@createdBy,@driver,@locationId,@dateArrived,@towedFrom,@reasonForImpound,@reasonForImpoundOther,@impoundCity,@impoundCounty,@timeOfImpound,@dateDeemedAbandoned,@ticketNumber); SET impoundId = LAST_INSERT_ID();"
私はエラーを取得する:
Unknown system variable 'impoundId'
最終的に、私は最後の自動インクリメント値を取得しようとしているが、私はへの切り替えを計画し、他のアプリケーションで私のコードの他のセクションがあります出力パラメータに依存するMYSQL。私はまだストアドプロシージャを使用していませんが、現時点では、これをMSSQLでどのように使用したのと同様の方法で動作させたいと考えています。
ありがとうございます。