![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi Karahan, Please try to add a ';' at the end of the insert SQL statement. It has to be "insert into tblUser (username,password) values(?,?); set ?=SCOPE_IDENTITY()". In OdbcCommand requires the SQL statements to be separated by ';'. Please also set the Size property of the parameter. Because if we specify the parameter type, we have to set the size, or some exception might be thrown by ADO .net. If anything is unclear, please feel free to reply to the post. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Hi Karahan, It seems that we cannot use '?' as parameter in SET statement in ODBC .NET provider. I think you can try the following code for substitution. OdbcCommand cmd = new OdbcCommand("insert into tblUser (username,password) values(?,?); SELECT SCOPE_IDENTITY()",conn); OdbcParameter [] arParms = new OdbcParameter[2]; arParms[0] = new OdbcParameter("@username", OdbcType.VarChar, 50 ); arParms[0].Value = aUser.Username; arParms[1] = new OdbcParameter("@password", OdbcType.VarChar, 50 ); arParms[1].Value = aUser.Password; cmd.Parameters.Add(arParms[0]); cmd.Parameters.Add(arParms[1]); int id = (int)cmd.ExecuteScalar(); If anything is unclear, please feel free to reply to the post. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Hi Karahan, Output parameters are supported in ODBC .net provider. However, they cannot be used in the SET statement. They are used to get the return value or output parameter of a stored procedure or something like that. Here are some KB articles for your reference: http://support.microsoft.com/default...b;en-us;177736 http://support.microsoft.com/default...b;en-us;310130 Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |