<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE> RODBC</TITLE>
</HEAD>
<BODY>
<BR>
<P><FONT SIZE=2>I'm trying to get the RODBC package to work with a MS Sql database (Wonderware's InSQL). I'm able to connect to the database using the following:</FONT></P>
<P><FONT SIZE=2>version</FONT>
<BR><FONT SIZE=2> _ </FONT>
<BR><FONT SIZE=2>platform i386-pc-mingw32 </FONT>
<BR><FONT SIZE=2>arch x86 </FONT>
<BR><FONT SIZE=2>os Win32 </FONT>
<BR><FONT SIZE=2>system x86, Win32 </FONT>
<BR><FONT SIZE=2>status Under development (unstable)</FONT>
<BR><FONT SIZE=2>major 1 </FONT>
<BR><FONT SIZE=2>minor 4.0 </FONT>
<BR><FONT SIZE=2>year 2001 </FONT>
<BR><FONT SIZE=2>month 10 </FONT>
<BR><FONT SIZE=2>day 29 </FONT>
<BR><FONT SIZE=2>language R </FONT>
<BR><FONT SIZE=2>> library(RODBC)</FONT>
<BR><FONT SIZE=2>library(RODBC)</FONT>
</P>
<P><FONT SIZE=2>> channel <- odbcConnect("SCADA2","ways1","LO&B*O",case="msaccess")</FONT>
<BR><FONT SIZE=2>> channel</FONT>
<BR><FONT SIZE=2>channel</FONT>
<BR><FONT SIZE=2>[1] 0</FONT>
</P>
<P><FONT SIZE=2>And an abbreviated table list is:</FONT>
</P>
<P><FONT SIZE=2>...</FONT>
<BR><FONT SIZE=2>25 Runtime dbo AnalogHistory TABLE</FONT>
<BR><FONT SIZE=2>...</FONT>
</P>
<P><FONT SIZE=2>A abbreviated Column List is as follows:</FONT>
</P>
<P><FONT SIZE=2>> odbcColumns(channel,"AnalogHistory")</FONT>
<BR><FONT SIZE=2>odbcColumns(channel,"AnalogHistory")</FONT>
<BR><FONT SIZE=2>[1] 1</FONT>
<BR><FONT SIZE=2>> sqlGetResults(channel)</FONT>
<BR><FONT SIZE=2>sqlGetResults(channel)</FONT>
</P>
<P><FONT SIZE=2> TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME</FONT>
<BR><FONT SIZE=2>1 Runtime dbo AnalogHistory DateTime 11 datetime</FONT>
<BR><FONT SIZE=2>2 Runtime dbo AnalogHistory TagName 12 varchar</FONT>
<BR><FONT SIZE=2>3 Runtime dbo AnalogHistory Value 6 float</FONT>
<BR><FONT SIZE=2>4 Runtime dbo AnalogHistory Quality -6 tinyint</FONT>
<BR><FONT SIZE=2>5 Runtime dbo AnalogHistory QualityDetail 4 int</FONT>
<BR><FONT SIZE=2>6 Runtime dbo AnalogHistory wwTagKey 4 int</FONT>
</P>
<P><FONT SIZE=2>...</FONT>
</P>
<P><FONT SIZE=2>When I try to query the table, I get:</FONT>
</P>
<P><FONT SIZE=2>> test <- sqlQuery(channel,"select DateTime, value from AnalogHistory </FONT>
<BR><FONT SIZE=2>> where Tagname = 'a055-re-0020_ph_pv_flt' and DateTime >= 'nov 1, 2001 </FONT>
<BR><FONT SIZE=2>> 2:00pm'")</FONT>
</P>
<P><FONT SIZE=2>> test</FONT>
<BR><FONT SIZE=2>test</FONT>
<BR><FONT SIZE=2>[1] "37000 201 [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'sp_prepare' expects parameter '@stmt', which was not supplied."</FONT></P>
<P><FONT SIZE=2>[2] "[RODBC]ERROR: Could not SQLPrepare" </FONT>
</P>
<P><FONT SIZE=2>Any thoughts? </FONT>
</P>
<P><FONT SIZE=2>Shawn Way</FONT>
<BR><FONT SIZE=2>Tanox, Inc.</FONT>
</P>
</BODY>
</HTML>