PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
RE: Help with ADO.net message "Failure creating file"
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
RE: Help with ADO.net message "Failure creating file"
![]() |
RE: Help with ADO.net message "Failure creating file" |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Well I got another pair of eyes to look at my "Select INTO" statement.
Here is what I had : Dim aidSql As String = "Select * INTO [Excel 8.0;Database= " & holdFlNme & > "] FROM [positions_sold04]" And here is my problem : OMIT SPACE after Database= Correct String: Dim aidSql As String = "Select * INTO [Excel 8.0;Database=" & holdFlNme & > "] FROM [positions_sold04]" Can you see the difference ???? -- Gordon "Gordon" wrote: > Hi ; > > Assuming: > > Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" > & sPath & ";Persist Security Info=False" > Dim Conn As OleDbConnection = New OleDbConnection(connString) > > If Conn.State = ConnectionState.Closed Then > Conn.Open() > End If > > I am trying to create an Excel 2003 workbook using a SELECT statement i.e. > > > Dim aidSql As String = "Select * INTO [Excel 8.0;Database= " & holdFlNme & > "] FROM [positions_sold04]" > > Then I pass aidSQL to a function which does this : > > createSS(aidSql) > > Sub createSS(ByVal aQryString As String) > > Dim cmd = New OleDbCommand(aQryString, Conn) > cmd.CommandType = CommandType.Text > cmd.CommandText = aQryString > > Try > result = cmd.ExecuteNonQuery() > MsgBox("#of Records Processed : " + result.ToString()) > Debug.WriteLine("Rows Processed :", result.ToString()) > Catch exp As Exception > Debug.WriteLine("Exception Ocurred :" + exp.Message.ToString()) > MsgBox("Exception Ocurred :" + exp.Message.ToString()) > End Try > > End Sub > > But when I try to execute the app I get the very helpful error message > "Failure creating file" > > Can anyone see a problem with the code ? > > Thanks, > > > > > -- > Gordon |
|
|
|
#2 |
|
Guest
Posts: n/a
|
When troubleshooting SQL statements embedded in your code it's helpful
to either stick them in a messagebox our a writeline statement so that you can examine the output before attempting to execute the statements. It's very difficult to detect small syntax errors just by looking at the lines of code. --Mary On Thu, 21 Dec 2006 14:02:01 -0800, Gordon <Gordon@discussions.microsoft.com> wrote: >Well I got another pair of eyes to look at my "Select INTO" statement. > >Here is what I had : > > Dim aidSql As String = "Select * INTO [Excel 8.0;Database= " & holdFlNme & >> "] FROM [positions_sold04]" > >And here is my problem : OMIT SPACE after Database= > >Correct String: > > Dim aidSql As String = "Select * INTO [Excel 8.0;Database=" & holdFlNme >& >> "] FROM [positions_sold04]" > >Can you see the difference ???? |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

