PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET RE: Help with ADO.net message "Failure creating file"

Reply

RE: Help with ADO.net message "Failure creating file"

 
Thread Tools Rate Thread
Old 21-12-2006, 10:02 PM   #1
=?Utf-8?B?R29yZG9u?=
Guest
 
Posts: n/a
Default RE: Help with ADO.net message "Failure creating file"


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

  Reply With Quote
Old 22-12-2006, 05:23 PM   #2
Mary Chipman [MSFT]
Guest
 
Posts: n/a
Default Re: Help with ADO.net message "Failure creating file"

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 ????

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off