K
K B
Hi, I'm using the following and the insert portion works fine but I'm
not getting the return value (TicketID) which is the identify column of
the table. I can't figure out what I'm missing; all examples I see use
stored procs but I need to use a string command for this.
Dim sSQL As String = "INSERT INTO eTicket(Priority, Category)
VALUES(@iPriority, @iCategory)"
Dim cmd As DbCommand = db.GetSqlStringCommand(sSQL)
db.AddInParameter(cmd, "@iPriority", SqlDbType.Int, iPriority)
db.AddInParameter(cmd, "@iCategory", SqlDbType.Int, iCategory)
db.AddOutParameter(cmd, "@TicketID", SqlDbType.Int, 4)
db.ExecuteNonQuery(cmd)
*******INSERT COMPLETES SUCCESSFULLY******
Dim iTicketID As Integer = db.GetParameterValue(cmd, "TicketID")
Am I doing something wrong in the sql command string?
Thanks,
KB
not getting the return value (TicketID) which is the identify column of
the table. I can't figure out what I'm missing; all examples I see use
stored procs but I need to use a string command for this.
Dim sSQL As String = "INSERT INTO eTicket(Priority, Category)
VALUES(@iPriority, @iCategory)"
Dim cmd As DbCommand = db.GetSqlStringCommand(sSQL)
db.AddInParameter(cmd, "@iPriority", SqlDbType.Int, iPriority)
db.AddInParameter(cmd, "@iCategory", SqlDbType.Int, iCategory)
db.AddOutParameter(cmd, "@TicketID", SqlDbType.Int, 4)
db.ExecuteNonQuery(cmd)
*******INSERT COMPLETES SUCCESSFULLY******
Dim iTicketID As Integer = db.GetParameterValue(cmd, "TicketID")
Am I doing something wrong in the sql command string?
Thanks,
KB