J
Joe Handelsman
Maybe this is already a know issue. I insert a lot of data into a SQLCE
database from a remote SQL database using a prepared insert statement,
basically imitating an RDA Pull. It seems to work well, but when I look at
the SQLCE database, the first row of the table has no values for any string
datatype. In other words, all the rows come back fine, except for the first
row returned, where then any string value is empty. Numeric data types are
fine. I've checked all the tables I use this method on and this error
happens everywhere, any string value has an empty value in its first row,
all subsequent rows are fine. I've stepped through the insert statement,
and it seems that the data is being passed OK. Below is the code, please
let me know if this is some kind of error, or if its just me.
Thanks,
Joe
'create table
g_sqlCommand.CommandText = "CREATE TABLE table_unit ("
g_sqlCommand.CommandText = g_sqlCommand.CommandText & "table_id_pk smallint
NOT NULL ,"
g_sqlCommand.CommandText = g_sqlCommand.CommandText & "table_name nvarchar
(12) NOT NULL) "
g_sqlCommand.ExecuteNonQuery()
'creat prepared statement
cmd.Parameters.Clear()
cmd.CommandText = "insert into table_unit (table_id_pk, table_name)
values(?,?);"
cmd.Parameters.Add("p1", SqlDbType.SmallInt)
cmd.Parameters.Add("p2", SqlDbType.NVarChar)
cmd.Prepare()
'do inserts
Me.m_sqlCommand.CommandText = "Select table_id_pk, table_name from
table_unit;"
sqlreader = Me.m_sqlCommand.ExecuteReader
While sqlreader.Read
cmd.Parameters("p1").Value = sqlreader.GetInt16(0)
cmd.Parameters("p2").Value = sqlreader.GetString(1)
cmd.ExecuteNonQuery()
End While
database from a remote SQL database using a prepared insert statement,
basically imitating an RDA Pull. It seems to work well, but when I look at
the SQLCE database, the first row of the table has no values for any string
datatype. In other words, all the rows come back fine, except for the first
row returned, where then any string value is empty. Numeric data types are
fine. I've checked all the tables I use this method on and this error
happens everywhere, any string value has an empty value in its first row,
all subsequent rows are fine. I've stepped through the insert statement,
and it seems that the data is being passed OK. Below is the code, please
let me know if this is some kind of error, or if its just me.
Thanks,
Joe
'create table
g_sqlCommand.CommandText = "CREATE TABLE table_unit ("
g_sqlCommand.CommandText = g_sqlCommand.CommandText & "table_id_pk smallint
NOT NULL ,"
g_sqlCommand.CommandText = g_sqlCommand.CommandText & "table_name nvarchar
(12) NOT NULL) "
g_sqlCommand.ExecuteNonQuery()
'creat prepared statement
cmd.Parameters.Clear()
cmd.CommandText = "insert into table_unit (table_id_pk, table_name)
values(?,?);"
cmd.Parameters.Add("p1", SqlDbType.SmallInt)
cmd.Parameters.Add("p2", SqlDbType.NVarChar)
cmd.Prepare()
'do inserts
Me.m_sqlCommand.CommandText = "Select table_id_pk, table_name from
table_unit;"
sqlreader = Me.m_sqlCommand.ExecuteReader
While sqlreader.Read
cmd.Parameters("p1").Value = sqlreader.GetInt16(0)
cmd.Parameters("p2").Value = sqlreader.GetString(1)
cmd.ExecuteNonQuery()
End While