Re: SQLCeConnection



When you have a DataReader open and you've issued a Read command, you don't
need ExecuteNonQuery to get data. Just use objDataReader.GetString(0) to get
the first column's data, etc.

--
Ginny Caughey
Device Application Development MVP


<amiga500@xxxxxxxxx> wrote in message
news:1164127121.034683.262880@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Oh God thank you guys for everything you have done. That really solved
the delima of what is the point for the SQLCe all together. Phew, that
made life easier.

However, I just need one more advice and I am set for sure.

This is the code below for the pocketpc:

Dim objConn As SqlConnection = Nothing
Dim objEngine As SqlCeEngine = Nothing
Dim objComm As New SqlCommand
Dim objDataReader As SqlDataReader = Nothing
Dim txtItemNumber As String

'Dim objDrItems As SqlCeDataAdapter
'"User ID=DSUSER;PASSWORD=silentk;Data
Source=NTSERVER-2;Initial
'Catalog=Direct Source System;Persist Security
Info=False;Packet
'Size=4096"
'objEngine.LocalConnectionString = "Data Source=NTSERVER-2"
'objEngine.CreateDatabase()
'objEngine = New SqlCeEngine("User
ID=DSUSER;PASSWORD=silentk;Data Source=NTSERVER-2;Initial
Catalog=Direct Source System;Persist Security Info=False;Packet
Size=4096")
'objEngine.CreateDatabase()
'objEngine.Dispose()
' 10.12.0.8
Try
objConn = New SqlConnection("User
ID=DSUSER;PASSWORD=silentk;Data Source=10.12.0.8;Initial Catalog=Direct
Source System;Persist Security Info=False;Packet Size=4096")
objComm.CommandText = "SELECT * FROM Products"
objComm.CommandType = CommandType.Text
objConn.Open()
objComm = New SqlCommand(objComm.CommandText, objConn)
objDataReader = objComm.ExecuteReader
Catch
MsgBox(Err.Description)
End Try

Try
While objDataReader.Read = True
txtItemNumber = objComm.ExecuteNonQuery
End While
objConn.Close()
Catch
MsgBox(Err.Description)
End Try
MsgBox(txtItemNumber)

I get an error exactly right here:
objDataReader = objComm.ExecuteReader

on the above line it says:
"There is already an open DataReader associated with this Connection or
Command which must be closed first."

But it makes absolutely no sense since I just started opening the file.
What does that mean?



.



Relevant Pages

  • RE: Run a Stored Procedure from Excel
    ... You also want to find out if you have a rsDW variable defined. ... Your code had a semicolon between the 2nd command and the ... Dim cnnDW As ADODB.Connection ... Set cnnDW = New ADODB.Connection ...
    (microsoft.public.excel.programming)
  • RE: Run a Stored Procedure from Excel
    ... "You also want to find out if you have a rsDW variable defined. ... Your code had a semicolon between the 2nd command and the ... Dim cnnDW As ADODB.Connection ... Set cnnDW = New ADODB.Connection ...
    (microsoft.public.excel.programming)
  • RE: Open Access 2003 or 2007 from Excel
    ... 'EXAMPLE OF ACCESS COMMAND TO CONTROL FORMS ... 'Dim dbMain As ADODB.Connection ... 'Dim dbMain As ADODB.Connection 'compile error: ... new computers that now have VISTA as the OS. ...
    (microsoft.public.excel.programming)
  • Re: Multiple table in dataset query
    ... If a row is marked as Modified, it will run your query defined in the ... Update Command object. ... Dim UpdateStaffCmd As New OleDb.OleDbCommand ... Private Sub frmStaff_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.framework.adonet)
  • Tool to get MCP ODT at Windows CMD prompt
    ... You basically send a series of ODT commands of your choosing, once, or in a loop, and get the output right in the command ... Dim sHostname ... Sub WriteIt ... WriteIt "" ...
    (comp.sys.unisys)