|
-
Jun 28th, 2010, 06:05 AM
#1
Thread Starter
Fanatic Member
Why this exception?
Code:
con = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=db1.mdb")
02 con.Open()
03 cmd = New OleDbCommand("Select * from Table1 where Name='gautam';" & "Select * from Table1 where Name='arijit';" & "Select * from Table1 where Name='muah'", con)
04 Dim dr As OleDbDataReader
05 dr = cmd.ExecuteReader()
06 dr.Read()
07 textBox1.Text = dr(0).ToString()
08 textBox2.Text = dr(1).ToString()
09 textBox3.Text = dr(2).ToString()
10 textBox4.Text = dr(3).ToString()
11 dr.NextResult()
12 dr.Read()
13 textBox5.Text = dr(0).ToString()
14 textBox6.Text = dr(1).ToString()
15 textBox7.Text = dr(2).ToString()
16 textBox8.Text = dr(3).ToString()
17 dr.NextResult()
18 dr.Read()
19 textBox9.Text = dr(0).ToString()
20 textBox10.Text = dr(1).ToString()
21 textBox11.Text = dr(2).ToString()
22 textBox12.Text = dr(3).ToString()
23 dr.Close()
24 cmd.Dispose()
25 con.Close()
i am getting this exception:

please help
-
Jun 28th, 2010, 06:12 AM
#2
Re: Why this exception?
I don't think this is valid, you concatenated 3 select statement, which I've never seen before, where you should only be using one
Code:
cmd = New OleDbCommand("Select * from Table1 where Name='gautam';" & "Select * from Table1 where Name='arijit';" & "Select * from Table1 where Name='muah'", con)
You should be using something like :
Code:
Select * from Table1 where Name='gautam' OR Name = 'arijit' OR Name = 'muah';
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jun 28th, 2010, 06:22 AM
#3
Thread Starter
Fanatic Member
Re: Why this exception?
nope........you changed the entire meaning of my sql statement
first i select the entire row where Name ='gautam' ,then i select entire row where name='arijit' and last i select entire row where name='much'
Then i populate the datareader with these three sql statements one aftre another using the nextresult() and populate the corresponding textbox.......
-
Jun 28th, 2010, 06:33 AM
#4
Re: Why this exception?
As far as I know Microsoft.Jet.Oledb doesn't support multiple queries in single query statement.
-
Jun 28th, 2010, 06:34 AM
#5
Re: Why this exception?
 Originally Posted by HowTo
nope........you changed the entire meaning of my sql statement
first i select the entire row where Name ='gautam' ,then i select entire row where name='arijit' and last i select entire row where name='much'
Then i populate the datareader with these three sql statements one aftre another using the nextresult() and populate the corresponding textbox.......
I understand that, but what I'm actually wondering is can you really use 3 select statement within the same OleDbCommand ?
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jun 28th, 2010, 06:41 AM
#6
Thread Starter
Fanatic Member
Re: Why this exception?
 Originally Posted by Pradeep1210
As far as I know Microsoft.Jet.Oledb doesn't support multiple queries in single query statement.
then it means i cant use the nextResult() of the datareader when i am using the oledb?
-
Jun 28th, 2010, 06:48 AM
#7
Re: Why this exception?
 Originally Posted by HowTo
then it means i cant use the nextResult() of the datareader when i am using the oledb?
Atleast not with the Microsoft.Jet.Oledb provider as far as I know.
-
Jun 28th, 2010, 06:57 AM
#8
Re: Why this exception?
 Originally Posted by HowTo
then it means i cant use the nextResult() of the datareader when i am using the oledb?
Looks like you could do it using the SqlCommand instead of the OleDbCommand as you can see here.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jun 28th, 2010, 07:07 AM
#9
Fanatic Member
Re: Why this exception?
 Originally Posted by stlaural
Looks like you could do it using the SqlCommand instead of the OleDbCommand as you can see here.
ya actually i was also trying to do it by having a look at the same page of the msdn.Anyways,nice to know that oledb cant handle these kinds of sql queries......
may i know what are these sql queries called(which contains more than 1 select statement as shown in the code)?
-
Jun 28th, 2010, 07:16 AM
#10
Re: Why this exception?
It is not limited to SELECT type queries only. It can be any valid sql query.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|