Run multiple queries simultaneously with SQL Compact 3.5???

  • Thread starter Thread starter Guy
  • Start date Start date
G

Guy

is it possible to have several queries in 1 query command (as far as i read
on the Microsoft pages this should be possible but i don't succeed):
in fact something like:

....
string sql = string.Format(select * from A; select * from B;);
....
 
Guy,

Here is an example of batching 2 select statements:

Dim cn As New SqlConnection("Data Source=(local)\SQLExpress;Initial
Catalog=ProjectTrackerSQL;User ID=sa;Password=xxxx")

Dim cmd As New SqlCommand
Dim dr As SQLDataReader
Dim dt1, dt2 As New DataTable

cmd.CommandText = "Select * From Employees; Select * From Departments"
cn.Open()
cmd.Connection = cn
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)

dt1.Load(dr)
MsgBox(dt1.Rows.Count)

dt2.Load(dr)
MsgBox(dt2.Rows.Count)

dr.Close()

Kerry Moorman
 
Guy,

I don't believe SQL Compact Edition supports batch queries on a single
command object.

Kerry Moorman
 
Thanks.

Kerry,

ok, then i don't have to look any further when its not supported by SQL
Compact 3.5.
When I want a dataset with several db tables I suppose then I have to write
all queries in separate statements and build that way my dataset?

Guy
 
No. Not on the same connection. But you can open multiple connections on
different threads and execute them simultaneously.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
Guy said:
Thanks.

Kerry,

ok, then i don't have to look any further when its not supported by SQL
Compact 3.5.
When I want a dataset with several db tables I suppose then I have to write
all queries in separate statements and build that way my dataset?

Yes. No batching is possible. Also look out for scalar queries in the
projection, as these also don't work (SELECT (SELECT COUNT(*) FROM ... )
AS Amount, Foo FROM ... )

FB
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
"Regardless of conflicting docs"

That's the best my peers and I could come up with so we dropped it.

Thanks for the input!
 
Back
Top