
Signature
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
> I'm using VB.NET 2005 and SQL Express. I have WinApp set up and shows my
> clients with no problem. I receive a DBF file from a supplier and would
[quoted text clipped - 12 lines]
>
> Any assistance would be helpful.
Thanks Cindy.
OK, I ran the EXEC in SQL Server Management Studio and it came back
successfully and I can see my linked server under Server Objects/Linked
Servers (oddly enough)
When I debug my program and import the data, it comes back with "Incorrect
syntax near '.'."
I understand that parameterized queries are better ;-) so I did my best.
Where am I going wrong?
Here's the code:
Using cn = New
SqlConnection(Global.MyProgram.My.MySettings.Default.MyConnectionString)
Dim cm As SqlCommand = cn.CreateCommand
cm.CommandType = CommandType.Text
cm.CommandText = "Insert Into Previews Select * From @Server...@Table;"
cm.Parameters.AddWithValue("@Server", "D610_62RGC91")
cm.Parameters.AddWithValue("@Table", strShortDatabaseName)
cn.open()
cm.ExecuteNonQuery()
'Dim dr As DataReader = cm.ExecuteReader
cn.close()
End Using

Signature
TIA, Burt
===============================
There's nothing so permanent as
a temporary solution - Me.
===============================
> Hi Burt,
>
[quoted text clipped - 38 lines]
>>
>> Any assistance would be helpful.
Burtamus - 26 May 2006 22:42 GMT
Sorry, I hit a key before I was finished editing the entry. I try to keep my
edits nice and clean. No reason to quote a quote, etc.
BTW Cindy, I tried to go to your web page to get some other pointers of
FoxPro. It came up empty.

Signature
TIA, Burt
===============================
There's nothing so permanent as
a temporary solution - Me.
===============================
Cindy Winegarden - 26 May 2006 23:15 GMT
We've had some power outages lately and I need to check that the machine
it's on (lives behind my desk at home) is up and running. Thanks.

Signature
Cindy Winegarden MCSD, Microsoft Most Valuable Professional
cindy@cindywinegarden.com
> BTW Cindy, I tried to go to your web page to get some other pointers of
> FoxPro. It came up empty.
Cindy Winegarden - 30 May 2006 00:37 GMT
Hi Burt,
Instead of piecing together a command string with some parts, the table
names, as variables your code makes SQL Server think you're passing tables
as paramters. Does code like this work for you?
Dim cn1 As New SQLConnection( _
"Data Source=(local);Initial Catalog=Test;Integrated
Security=True")
cn1.Open()
Dim cmd1 As New SqlCommand( _
"Insert Into Customers Select * From
VFP_Northwind...Customers " + _
"Where CustomerID Like 'A%'", cn1)
cmd1.ExecuteNonQuery()
Dim targetTable As String = "Customers"
Dim sourceTable As String = "VFP_Northwind...Customers"
Dim criteria As String = "'B%'"
Dim cmd2 As New SqlCommand( _
"Insert Into " + targetTable + " Select * From " + _
sourceTable + " Where CustomerID Like " + criteria, cn1)
cmd2.ExecuteNonQuery()

Signature
Cindy Winegarden MCSD, Microsoft Most Valuable Professional
cindy@cindywinegarden.com
> Dim cm As SqlCommand = cn.CreateCommand
> cm.CommandType = CommandType.Text
[quoted text clipped - 4 lines]
>
> cm.Parameters.AddWithValue("@Table", strShortDatabaseName)