I am trying to execute a make table query in my vb.net program. The db that
I am accessing is an Access 2000 format db. The SQL code that I am using has
been cut and pasted from the SQL View having designed the query in the
design view of Access.
The code in question is below, I apologise for the length of the SQL
statement
Dim SqlComText As String = "SELECT TblCentreSessio n.ID,
TblCentreSessio n.Session AS [SessionID], TblSession.Sess ionYear AS [Session
Year], TblSession.Sess ionSeason AS [Session Season], TblCentre.Centr eName AS
[Centre Name], TblExaminer.Exa minerCode AS [Examiner Code],
TblExaminer.Exa minerSName AS [Examiner Surname], TblExaminer.Exa minerMName
AS [Examiner Middle Name], TblExaminer.Exa minerFName AS [Examiner First
Name], TblSyllabus.Syl labusName AS [Syllabus Name],
CLng([TblCandidate].[CandidateID]) AS [Candidate ID], TblCandidate.SN ame AS
[Candidate Surname], TblCandidate.MN ame AS [Candidate Middle Name],
TblCandidate.FN ame AS [Candidate First Name], CLng([TblSubject].[SubjectID])
AS [Subject ID], TblSubject.Subj ectName AS [Subject Name],
CLng([TblGrade].[GradeID]) AS [Grade ID], TblGrade.GradeN ame AS [Grade
Name], TblExamResults. Result, TblExamResults. AdjResult1 AS [Adjusted Result
1], TblExamResults. AdjResult2 AS [Adjusted Result 2], tblNote.Notes AS
[Adjustment Notes] INTO [Results Table] IN '" & ChosenFilename & "' FROM
tblNote RIGHT JOIN (((((TblCentreS ession LEFT JOIN TblCentre ON
TblCentreSessio n.Centre = TblCentre.Centr eCode) LEFT JOIN TblSession ON
TblCentreSessio n.Session = TblSession.Sess ionID) LEFT JOIN TblSyllabus ON
TblCentreSessio n.Syllabus = TblSyllabus.Syl labusID) LEFT JOIN TblExaminer ON
TblCentreSessio n.Examiner = TblExaminer.Exa minerCode) RIGHT JOIN
(((TblCandidate RIGHT JOIN TblExamResults ON TblCandidate.Ca ndidateID =
TblExamResults. CandidateID) LEFT JOIN TblSubject ON TblExamResults. Subject =
TblSubject.Subj ectID) LEFT JOIN TblGrade ON TblExamResults. Grade =
TblGrade.GradeI D) ON TblCentreSessio n.ID = TblExamResults. CentreSession) ON
tblNote.ExamID = TblExamResults. ID WHERE (((TblCentreSes sion.Session)=" &
chosenSessionID & ") AND ((TblExamResult s.Result) Is Not Null And
(TblExamResults .Result)>0)) ORDER BY TblCentreSessio n.ID"
Dim cnn1 As New OleDb.OleDbConn ection("Provide r=Microsoft.Jet .OLEDB.4.0;Jet
OLEDB:System Database=" & systemdblocatio n & ";Data Source=" &
examdblocation & ";User ID=" & User & ";Password= " & PWord)
Dim cmd1 As New OleDb.OleDbComm and
cnn1.Open()
Dim runningcount As Integer = 0
Try
With cmd1
.Connection = cnn1
.CommandText = SqlComText
.ExecuteScalar( )
End With
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try
cnn1.Close()
I have tried executing it but each time I get the following error:
"System.Data.Ol eDb.OleDbExcept ion: IErrorInfo.GetD escription failed with
E_FAIL(0x800040 05).
at System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32
hr)
at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object&
executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r
behavior, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
at System.Data.Ole Db.OleDbCommand .ExecuteScalar( )
at MYDB.ExportForm .btnExport_Clic k(Object sender, EventArgs e) in
C:\Documents and Settings\Admini strator\My Documents\Visua l Studio
Projects\myDB\m yDB\ExportForm. vb:line 146;"
Any help in understanding what I am doing wrong, or instructions on how to
do this better would me greatly appreciated.
Nov 20 '05
20 5224
Hi Neil,
I understand now what you want to do, however I hate SQL.
I do not know how deep Peters knowledge is of that, however meanwhile you
can try to see if you get more information by setting this before the catch
ex as exception (you can let that stay)
\\\
Catch sqlEx As SqlException
MessageBox.Show (sqlEx.ToString )
Catch ex as Exception
.......
End try
///
Maybe you get than some better information.
Cor
Hi Cor,
Thanks for this I will put the code in and see what happens. I'll post the
results to this thread.
Regards,
Neil R.
"Cor" <no*@non.com> wrote in message
news:un******** ******@TK2MSFTN GP12.phx.gbl... Hi Neil,
I understand now what you want to do, however I hate SQL.
I do not know how deep Peters knowledge is of that, however meanwhile you can try to see if you get more information by setting this before the
catch ex as exception (you can let that stay) \\\ Catch sqlEx As SqlException MessageBox.Show (sqlEx.ToString ) Catch ex as Exception ...... End try /// Maybe you get than some better information.
Cor
Hi Cor,
Thanks for this I will put the code in and see what happens. I'll post the
results to this thread.
Regards,
Neil R.
"Cor" <no*@non.com> wrote in message
news:un******** ******@TK2MSFTN GP12.phx.gbl... Hi Neil,
I understand now what you want to do, however I hate SQL.
I do not know how deep Peters knowledge is of that, however meanwhile you can try to see if you get more information by setting this before the
catch ex as exception (you can let that stay) \\\ Catch sqlEx As SqlException MessageBox.Show (sqlEx.ToString ) Catch ex as Exception ...... End try /// Maybe you get than some better information.
Cor
Hi Neil,
I am sorry if I have any confusion.
But have you tried to run the Query statement in Access Application
directly?
Will you get any error?
If no, you may try to simplify your SqlComText.
e.g. SqlComText="Sel ect * from tblNote"
So that we can isolate the problem to see what cause the problem.
Please make a try and let me know the result.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Neil,
I am sorry if I have any confusion.
But have you tried to run the Query statement in Access Application
directly?
Will you get any error?
If no, you may try to simplify your SqlComText.
e.g. SqlComText="Sel ect * from tblNote"
So that we can isolate the problem to see what cause the problem.
Please make a try and let me know the result.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Neil,
In addition, after I further research, it seems that there is reserved
keywords(Sessio n in your query statement) which may cause the problem.
Here is the list of the reserved keywords of OleDb and Access you may take
a look.
IDBInfo::GetKey words http://msdn.microsoft.com/library/de...us/oledb/htm/o
ledbidbinfo__ge tkeywords.asp
Keywords http://msdn.microsoft.com/library/de...us/oledb/htm/o
lapkeywords.asp
ACC2002: Reserved Words in Microsoft Access http://support.microsoft.com/?id=286335
So you may also try to change your querystring as below.
"Select [Session] From Table1"
That is to say, you may need to change the keyword in the select statement
into [keyword].
You may have a try and let me know the result.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Neil,
In addition, after I further research, it seems that there is reserved
keywords(Sessio n in your query statement) which may cause the problem.
Here is the list of the reserved keywords of OleDb and Access you may take
a look.
IDBInfo::GetKey words http://msdn.microsoft.com/library/de...us/oledb/htm/o
ledbidbinfo__ge tkeywords.asp
Keywords http://msdn.microsoft.com/library/de...us/oledb/htm/o
lapkeywords.asp
ACC2002: Reserved Words in Microsoft Access http://support.microsoft.com/?id=286335
So you may also try to change your querystring as below.
"Select [Session] From Table1"
That is to say, you may need to change the keyword in the select statement
into [keyword].
You may have a try and let me know the result.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Peter,
thanks for this. the query does run without a problem in Access, but not in
the .net app. This information about the word 'Session' fits perfectly
though. When I remove it the query runs without a problem.
Thankyou for your help,
Regards,
Neil R.
""Peter Huang"" <v-******@online.m icrosoft.com> wrote in message
news:ET******** ******@cpmsftng xa06.phx.gbl... Hi Neil,
In addition, after I further research, it seems that there is reserved keywords(Sessio n in your query statement) which may cause the problem.
Here is the list of the reserved keywords of OleDb and Access you may take a look.
IDBInfo::GetKey words http://msdn.microsoft.com/library/de...us/oledb/htm/o ledbidbinfo__ge tkeywords.asp
Keywords http://msdn.microsoft.com/library/de...us/oledb/htm/o lapkeywords.asp
ACC2002: Reserved Words in Microsoft Access http://support.microsoft.com/?id=286335
So you may also try to change your querystring as below. "Select [Session] From Table1"
That is to say, you may need to change the keyword in the select statement into [keyword].
You may have a try and let me know the result.
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no
rights.
Hi Peter,
thanks for this. the query does run without a problem in Access, but not in
the .net app. This information about the word 'Session' fits perfectly
though. When I remove it the query runs without a problem.
Thankyou for your help,
Regards,
Neil R.
""Peter Huang"" <v-******@online.m icrosoft.com> wrote in message
news:ET******** ******@cpmsftng xa06.phx.gbl... Hi Neil,
In addition, after I further research, it seems that there is reserved keywords(Sessio n in your query statement) which may cause the problem.
Here is the list of the reserved keywords of OleDb and Access you may take a look.
IDBInfo::GetKey words http://msdn.microsoft.com/library/de...us/oledb/htm/o ledbidbinfo__ge tkeywords.asp
Keywords http://msdn.microsoft.com/library/de...us/oledb/htm/o lapkeywords.asp
ACC2002: Reserved Words in Microsoft Access http://support.microsoft.com/?id=286335
So you may also try to change your querystring as below. "Select [Session] From Table1"
That is to say, you may need to change the keyword in the select statement into [keyword].
You may have a try and let me know the result.
Best regards,
Peter Huang Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no
rights.
Peter,
Great.
As I have said that in this thread I hate SQL and this is one of the
reasons, so many impossible reserved words
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kulnor |
last post by:
My hosting company upgraded yesterday to pHp 4.3.10. Since then, all my
INSERT/UPDATE/DELET query on our MS-SQL database seem to fail. No
specific error message is returned by mssql_get_last_message(). The
SELECT statements work fine.
If I test on my local server running 4.3.9 the application behaves
properly. Any suggestion/idea?
thanks
|
by: Not Me |
last post by:
Hi,
I have a stored procedure, that works perfectly when run from the query
analyser, however if I run it through access vba, (using exec) I get a
runtime error 208: invalid object name '#tmpContact'.
Any ideas why this happens? The temporary table #tmpContact is used in
the procedure, but as I say, it all works fine from the analyser.
Thanks,
|
by: js |
last post by:
I am using SQL Server 2000. I am getting the following error when
executing the following query. The query joins a view
.dbx.dbo.vwreports that resides on a linked server. I can sort
on fields on D table or R view individually, but some fields take a
long time to sort even they are on non-cluster indexes. I can not sort
on any field in table E, K, and L at all. Also I tried to save this
query as a view in the local server. SQL Server...
|
by: Davy Faassen |
last post by:
Hi,
In the CLI guide and reference i've read about the possibility of getting status
information when using arrays to input parameter values. This i've achieved as
described with the SQL_ATTR_PARAM_STATUS_PTR attribute of the SQLSetStmtAttr()
function.
I'm trying to do a bulk INSERT and if there are already records in the target
table, i want to update those records that were already present. Depending on
the status information just...
|
by: Neil Hindry |
last post by:
I wonder if you can help me.
I have setup an address-book database in Access XP. I have the first name &
surname as separate fields. As I wanted to sort my database by surname and
then by first name I had surname before first name when I created the
fields of my database..
To do the sort (in table view) I highlighted the two columns (fields), in
this case surname and first name, and selected sort. Access then sorted the
database by...
| |
by: Neil Robbins |
last post by:
I am trying to execute a make table query in my vb.net program. The db that
I am accessing is an Access 2000 format db. The SQL code that I am using has
been cut and pasted from the SQL View having designed the query in the
design view of Access.
The code in question is below, I apologise for the length of the SQL
statement
Dim SqlComText As String = "SELECT TblCentreSession.ID,
TblCentreSession.Session AS , TblSession.SessionYear AS...
|
by: Not4u |
last post by:
Hello
Config : SQL 2000 on WIN 2000 (IIS 5.0)
In my ASP page for some queries i have this error :
Microsoft OLE DB Provider for SQL Server error '80040e31'
Timeout expired
|
by: Daz |
last post by:
Hi everyone.
I was faced with the choice of whether my problem is indeed a PHP
problem or a MySQL. I have decided it's a PHP problem as I don't
experience the same problem when I execute the same query at the CLI.
I am having trouble executing a large query through my PHP script. It
takes about 7-11 seconds on
average to execute, whereas the same query only takes 0.01 seconds to
execute through the CLI.
|
by: raghuvendra |
last post by:
Hi
I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button.
All these are aligned in a row. And Each Category Name has its corresponding Category order, Input field and a submit button.
The Category name is being fetched from the oracle db along with the corresponding Category order.
In the corresponding input field (text box) the user enters a new category order which gets stored in the...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |