我找到好多,都是需要用到ODBC的,我想请问一下,如果不用ODBC,能不能与SQL连起来,用ADO可以吗?怎么实现?谢谢.....!!!!
------解决方案--------------------------------------------------------
vfp中用ado访问sql数据库
*----------------------------
FUNCTION DalBuildMarket(vMarket as String,curName as String ) as integer
PRIVATE all
result=0
storeProd = "TOWNSelByName2 "
this.strConn= "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=test;Data Source=127.0.0.1 "
TRY
***********************
LOCAL oConn AS ADODB.Connection,cStrung AS Character,oRs AS ADODB.RecordSet,oCmd AS ADODB.Command
oConn=CREATEOBJECT( "ADODB.Connection ")
oConn.Open(this.strConn)
oCmd=CREATEOBJECT( "ADODB.Command ")
oCmd.ActiveConnection=oConn
oCmd.CommandText=storeProd
oCmd.CommandType=4 && 调用存储过程
**初始化参数
oCmd.Parameters.Append(oCmd.CreateParameter( "vProName ",200,1,100, " "))
oCmd.Parameters.Append(oCmd.CreateParameter( "vTownName ",200,1,100, " "))
**赋值
oCmd.Parameters( "vTownName ").Value=vMarket
oRs=oCmd.Execute()
DO WHILE NOT oRs.EOF
INSERT INTO (curName) (id,provinceName ,TownName ) value(oRs.Fields(0).Value ,oRs.Fields(1).Value ,oRs.Fields(2).Value )
ors.MoveNext
result=result+1
ENDDO
oConn.Close()
CATCH
IF oConn.State <> 0
oConn.Close()
ENDIF
result=-1
ENDTRY
RETURN result
ENDFUNC