Boyd564852


In the following code snippet, the stored procedure executes up to the

iRet = vciSqlCommand.ExecuteNonQuery();

command and fails with error:

System.Data.SqlClient.SqlException: Incorrect syntax near 'value'.

That would point to the

" = @data_Param where

section.

So what is the proper syntax

Code Snippet

SqlParameter data_Param = new SqlParameter("@data_Param", SqlDbType.Variant);

SqlCommand vciSqlCommand = new SqlCommand();

switch ((vcidatatype)FieldDef.ivcidatatype)

{ // read in the binary data!!!!!!

case vcidatatype.eENGUNITS: data_Param.Value = Encoding.ASCII.GetString(r.ReadBytes(FieldDef.iLen)); break;

case vcidatatype.eLANADR: data_Param.Value = r.ReadInt16(); break;

case vcidatatype.eBYTESIZE: data_Param.Value = r.ReadByte(); break;

case vcidatatype.eFLOATSIZE: data_Param.Value = r.ReadSingle(); break;

case vcidatatype.eINT32SIZE: data_Param.Value = r.ReadUInt32(); break;

case vcidatatype.eFILLERBYTES: r.ReadBytes(FieldDef.iLen); break; // eat up empty bytes

default: FieldDef.ivcidatatype = (Int32)vcidatatype.eFILLERBYTES; break;

}

if (FieldDef.ivcidatatype != (Int32)vcidatatype.eFILLERBYTES)

{ // all but filler

vciSqlCommand.CommandText =

"update " + acPointType + "set " + FieldDef.sFldName +

" = @data_Param where VEC = " + acVECName +

" and name = " + acPointName;

vciSqlCommand.Connection = conn;

conn.Open();

iRet = vciSqlCommand.ExecuteNonQuery();

conn.Close();




Re: use of variant type parameter in ExecuteNonQuery()

Boyd


Silly typo.

No space before the "set", should be " set "!!!!