Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLExec()
Message
From
10/04/2002 05:00:52
 
 
To
09/04/2002 23:36:39
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00642520
Message ID:
00643050
Views:
17
Shaishav,

I don't think your problem is related to the connection. Rather it cannot find the table. Did you try SQLExec(gnConnHandle,'SELECT * FROM Orders','RESULT1'). Note the case of "Orders".

Try the following:
*-- connection string when using SQL Server security
lcConnectionStr = "DRIVER={SQL Server};"+;
                  "SERVER=ServerName;"+;
                  "DATABASE=northwind;"+;
                  "UID=YourUserId;"+;
                  "PWD=YourPassword"

*-- connection string when using NT security
*lcConnectionStr = "DRIVER={SQL Server};"+;
                  "SERVER=ServerName;"+;
                  "DATABASE=northwind;"+;
                  "TRUSTED_CONNECTION=yes"

*-- connect to SQL Server
lnSql = SQLSTRINGCONNECT(lcConnectionStr)

IF lnSql < 1
  *-- connection failed
ELSE
  SQLExec(lnSql,'SELECT * FROM Orders','RESULT1')
ENDIF
HTH
>Hi Daniel,
>
>First thanks for the reply,
>
>Following is the error returned by AERROR() function;
>
>------------------------------------
>1526
>
>Connectivity error: [Microsoft][ODBC SQL Server driver][SQL Server]Invalid object name 'orders'.
>
>[Microsoft][ODBC SQL Server driver][SQL Server]Invalid object name 'orders'.
>
>S0002
>
>208
>
>1
>
>.NULL.
>------------------------------------
>
>If I use ODBC connection to my VFP databases on remote server (withing LAN) it works fine. However if I use ODBC to SQL Server it won't work. Can you make our how do I establish a connection.
>
>Do I have to specify Northwind database, under the SQL Server??? How?
>
>TIA
>
>
>
>
>>Shaishav,
>>
>>Did you configure SQL Server to be case sensitive? If yes, then you must specify object names (tables, fields, etc) using the exact case. Try the following:
>>
>>SQLExec(gnConnHandle,'SELECT * FROM Orders','RESULT1')
>>
>>
>>Another thing to check if a SQLEXEC() fails is AERROR(). It will tell you what went wrong.
>>
>>HTH
>>>I'm trying to establish connection to SQL 2000 database on a server on my LAN. I successfully created a connection using my ODBC data source. however, when i try to run SQL query using SQLExec, it fails.
>>>
>>>Following is my code; can any one help me in this.
>>>
>>>I'm trying to connect to ORDERS table of Northwind Database.
>>>
>>>STORE SQLCONNECT('MRAD', 'sa') TO gnConnHandle
>>>IF gnConnHandle < 0
>>> = MESSAGEBOX('Cannot make connection', 16, 'SQL Connect Error')
>>>ELSE
>>> = MESSAGEBOX('Connection made', 48, 'SQL Connect Message')
>>> SQLExec(gnConnHandle,'SELECT * FROM ORDERS','RESULT1')
>>> SELECT RESULT1
>>> BROW
>>>ENDIF
>>>
>>>TIA
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform