Error ..

  • Thread starter Thread starter Yo
  • Start date Start date
Y

Yo

I have a database in SQL Server and I connect myself to this to pass the
data from a table to SQL Server CE but when 498 registrations go it sends me
an error and not continuous.

Which could be the problem ??

The code that I use is the following

Dim cmd As System.Data.SqlClient.SqlCommand
Dim dtr As System.Data.SqlClient.SqlDataReader
Dim oConn As System.Data.SqlClient.SqlConnection

oConn = New System.Data.SqlClient.SqlConnection("user
id=pocket;password=12345;database=pocketCE;server=10.21.109.5")
oConn.Open()

cmd = New System.Data.SqlClient.SqlCommand("Select codani, nomani
from hoja", oConn)
dtr = cmd.ExecuteReader()

Dim oConnCE As New SqlCeConnection("Data Source = \My
Documents\prueba.sdf")
Dim SQLUpd As SqlCeCommand = oConnCE.CreateCommand()
Dim cCod, cNom As String

oConnCE.Open()
While dtr.Read()
cCod = dtr("codani")
cNom = dtr("nomani")
SQLUpd.CommandText = "INSERT INTO Animal VALUES('" & Trim(cCod)
& "','" & Trim(cNom) & "')"
SQLUpd.ExecuteNonQuery()
End While

MsgBox("ok")
oConnCE.Close()
 
You might want to tell us what the error was and which line of code
generated it...

Paul T.
 
The error happens in the line

oConnCE.Open()
While dtr.Read()
cCod = dtr("codani")
cNom = dtr("nomani")
SQLUpd.CommandText = "INSERT INTO Animal VALUES('" & Trim(cCod)
& "','" & Trim(cNom) & "')"
SQLUpd.ExecuteNonQuery()
End While <<---- HERE

The table has 1450 registrations but when its goes for 498 it sends me there
an error.
I believe that the error could happen for the clause SQLUpd.ExecuteNonQuery
()


Paul G. Tobey said:
You might want to tell us what the error was and which line of code
generated it...

Paul T.
 
And the error was? If it is an exception, catch it and read out all of the
information in the exception object...

Paul T.

Yo said:
The error happens in the line

oConnCE.Open()
While dtr.Read()
cCod = dtr("codani")
cNom = dtr("nomani")
SQLUpd.CommandText = "INSERT INTO Animal VALUES('" & Trim(cCod)
& "','" & Trim(cNom) & "')"
SQLUpd.ExecuteNonQuery()
End While <<---- HERE

The table has 1450 registrations but when its goes for 498 it sends me
there
an error.
I believe that the error could happen for the clause
SQLUpd.ExecuteNonQuery
()
 
Please do as I asked in the previous messages and capture the exception and
look at what it's telling you. *You*, not us, are in the best position to
find the problem! You have it right there in the debugger in front of you!

Paul T.

Yo said:
An illustration of the error

http://www.davphantom.net/archivos/Dibuj1o.JPG

--

Paul G. Tobey said:
And the error was? If it is an exception, catch it and read out all of the
information in the exception object...

Paul T.

Yo said:
The error happens in the line

oConnCE.Open()
While dtr.Read()
cCod = dtr("codani")
cNom = dtr("nomani")
SQLUpd.CommandText = "INSERT INTO Animal VALUES('" & Trim(cCod)
& "','" & Trim(cNom) & "')"
SQLUpd.ExecuteNonQuery()
End While <<---- HERE

The table has 1450 registrations but when its goes for 498 it sends me
there
an error.
I believe that the error could happen for the clause
SQLUpd.ExecuteNonQuery
()


"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com>
escribió en el mensaje You might want to tell us what the error was and which line of code
generated it...

Paul T.

I have a database in SQL Server and I connect myself to this to pass the
data from a table to SQL Server CE but when 498 registrations go it
sends
me
an error and not continuous.

Which could be the problem ??

The code that I use is the following

Dim cmd As System.Data.SqlClient.SqlCommand
Dim dtr As System.Data.SqlClient.SqlDataReader
Dim oConn As System.Data.SqlClient.SqlConnection

oConn = New System.Data.SqlClient.SqlConnection("user
id=pocket;password=12345;database=pocketCE;server=10.21.109.5")
oConn.Open()

cmd = New System.Data.SqlClient.SqlCommand("Select codani,
nomani
from hoja", oConn)
dtr = cmd.ExecuteReader()

Dim oConnCE As New SqlCeConnection("Data Source = \My
Documents\prueba.sdf")
Dim SQLUpd As SqlCeCommand = oConnCE.CreateCommand()
Dim cCod, cNom As String

oConnCE.Open()
While dtr.Read()
cCod = dtr("codani")
cNom = dtr("nomani")
SQLUpd.CommandText = "INSERT INTO Animal VALUES('" &
Trim(cCod)
& "','" & Trim(cNom) & "')"
SQLUpd.ExecuteNonQuery()
End While

MsgBox("ok")
oConnCE.Close()
 
Back
Top