Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Moving from FoxPro's DBC to MSSQL Server
Message
From
09/11/2005 09:51:52
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01066358
Message ID:
01066764
Views:
14
>
>I have the task to move VFP application from native DBC database to MSSQL Server (MSDE).
>
>What are advices, suggestions, warnings when moving from VFP's DBC to MSSQL+remote views? Is there any sources to read in internet?
>
Giedrius..

I did that prg to go through a folder and every table on that folder become a source to create the tables on the MYSQL's server.. For MSSQL you need to do some few changes..
Private privStrConexao,privConexao

privStrConexao="DRIVER=MySQL ODBC 3.51 Driver;" +;
"SERVER=67.15.52.95;"             +;
"UID=myuser;"                      +;
"PWD=mypassword;"                    +;
"DATABASE=mydatabase;"                 +;
"WSID="+Substr(Sys(0),1,Atc(Sys(0),"#")-1)+";"
privConexao = Sqlstringconnect(privStrConexao)

If  privConexao < 1
    Messagebox( 'wasn't connected ! '+allt(str(privConexao)),48,'Error' )
Else
    Wait window "Connected.." nowait
Endif
cPath_temporario        =  "f:\myssystem\dbfs"  && place for local tables
cwtab_only              = "clients;"
cwtab_desn              = "gran_grade;email_list_;roteiros_itens;scripts;scripts_clientes;scripts_itens;tipos_respostas;empresa;roteiros;" && tables to remain only locally
nwtot                   = ADIR(aFiles , cPath_temporario+iif(right(cPath_temporario,1)="\","","/")+"*.dbf")


For i = 1 to alen(aFiles, 1)
	cwfile          = forcepath(aFiles[i, 1], cPath_temporario)
	cwtb            = lower(juststem(cwfile))
	If  cwtb+";"$cwtab_desn
		Loop
	Endif
	if  empty(cwtab_only)
	else
	    If  cwtb+";"$cwtab_only
	    else
	        loop
	    endif
	endif
	If  file(cwfile)
		Sele 0
		Use (cwfile) again alias tb_upload shared
	Else
		Loop
	Endif
	Sele tb_upload
	gnFieldcount   = AFIELDS(gaMyArray)  && Array with fields
	cwsqlfields    = ""
	For nCount = 1 TO gnFieldcount
		If  nCount > 1
			cwsqlfields =  cwsqlfields + ", "
		Endif
		cwsqlfields =  cwsqlfields + lower(gaMyArray(nCount,1))
		cwsqlf       = ""
		Do case
			Case "dthr_ocorr"$lower(gaMyArray(nCount,1))
				cwsqlf = " timestamp"
			Case gaMyArray(nCount,2) = "C"
				If  gaMyArray(nCount,3)>1
					cwsqlf = " varchar("+allt(str(gaMyArray(nCount,3)))+")"
				Else
					cwsqlf = " char("+allt(str(gaMyArray(nCount,3)))+")"
				Endif
			Case inlist(gaMyArray(nCount,2), "I", "N")
				If  gaMyArray(nCount,4) = 0
					If  gaMyArray(nCount,3) > 3
						cwsqlf = " tinyint("+allt(str(gaMyArray(nCount,3)))+")"
					Else
						cwsqlf = " int("+allt(str(gaMyArray(nCount,3)))+")"
					Endif
				Else
					cwsqlf = " dec("+allt(str(gaMyArray(nCount,3)))+", "+allt(str(gaMyArray(nCount,4)))+")"
				Endif
			Case gaMyArray(nCount,2) = "D"
				cwsqlf = " date"
			Case gaMyArray(nCount,2) = "T"
				cwsqlf = " datetime"
			Case gaMyArray(nCount,2) = "M"
				cwsqlf = " text"
			Case gaMyArray(nCount,2) = "L"
				cwsqlf = " tinyint(1)"
		Endcase
		cwsqlfields =  cwsqlfields + cwsqlf
	Endfor
	If  "campanhas"$cwtb .or. "log"$cwtb   && some few exceptions
		cwsqlfields = "cliente varchar(5), " + cwsqlfields
	Endif
	* to create an expr with the index keys
	cwsqlkeys = ""
	wkeyexpr  = "A"
	x         = 1
	wprefkey  = ""
	For nCount = 1 TO 254
		If !EMPTY(TAG(nCount))  && Verifica se há marcas no índice
		    *cwstrmk = iif(type("TAG(nCount)")="C", "'", "")
		    cwkey = ""+lower(KEY(nCount))+""
		    if  "+"$cwkey
		        do  while "+"$cwkey
		            cwkey = stuff(cwkey,at("+",cwkey),1,", ")
		        enddo
		    endif
		    if  "ttoc("$cwkey
		        do  while "ttoc("$cwkey
		            nwpos = at("ttoc(",cwkey)
		            cwkey = stuff(cwkey, nwpos,5,"")
		            if  at(",1)",cwkey) > 0
		                nwpos = at(",1)",cwkey)
		                cwkey = stuff(cwkey, nwpos, 3,"")
		            endif
		        enddo
		    endif
		    if  "substr("$cwkey
		        do  while "substr("$cwkey
		            nwpos = at("substr(",cwkey)
		            cwkey = stuff(cwkey, nwpos,7,"")
		            if  at(",1,8)",cwkey) > 0
		                nwpos = at(",1,8)",cwkey)
		                cwkey = stuff(cwkey, nwpos, 5,"")
		            endif
		        enddo
		    endif
			cwsqlkeys = cwsqlkeys + ", KEY " + lower(TAG(nCount)) + " (" + cwkey +  ") "
		Else
			Exit
		Endif
	Endfor

	*cwsqlstring = "CREATE TABLE "+cwtb+" ("+cwsqlfields+cwsqlkeys+")"
	cwsqlstring = "CREATE TABLE "+cwtb+" ("+cwsqlfields+")"
	nwret=SQLexec(privConexao, cwsqlstring)
	Do while nwret = 0
	Enddo
	Sele tb_upload
	Use
Endfor
SQLDISCONNECT(privConexao)
HTH

Claudio
"Now to him who is able to do immeasurably more than all we ask or imagine, according to his power that is at work within us, Ephesians 3:20
Previous
Reply
Map
View

Click here to load this message in the networking platform