1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
| Function MYSQLEXEC
Lparameters tnhandle, tcsql, tccursorname
tccursorname = Iif(Empty(tccursorname),'',tccursorname)
If SQLExec(tnhandle,tcsql,tccursorname) < 0
Do errhand With tcsql
Endif
Function errhand
Lparameters tcsql
If !Empty(tcsql)
lcerror=tcsql
Aerror(arrcheck)
For ix=1 To 7
lcerror = lcerror+Trans( arrcheck [ix])+ Chr(13)
Endfor
If Len(lcerror)<1062
Messagebox(lcerror,0,'Error def.')
Else
gnerrfile = Fcreate('_errFile.txt') && If not create it
If gnerrfile < 0 && Check for error opening file
Wait 'Cannot open or create output file' Window Nowait
Else && If no error, write to file
=Fwrite(gnerrfile , lcerror)
Endif
=Fclose(gnerrfile ) && Close file
If gnerrfile > 0
Modify File _errfile.txt Nowait && Open file in edit window
Endif
Endif
Endif
Function mysqlexecX
Lparameters tnhandle, tcsql, tccursorname
tccursorname = Iif(Empty(tccursorname),'',tccursorname)
If SQLExec(tnhandle,tcsql,tccursorname) < 0
If !Empty(tcsql)
lcerror=tcsql
Aerror(arrcheck)
If File('errors.txt') && Does file exist?
gnerrfile = Fopen('errors.txt',2) && If so, open read/write
x1=Fseek(gnerrfile,0,2)
Else
gnerrfile = Fcreate('errors.txt') && If not create it
x1=Fseek(gnerrfile,0,2)
Endif
If gnerrfile > 0 && Check for error opening file
For ix=1 To 7
=Fwrite(gnerrfile ,Trans( arrcheck [ix])+ Chr(13))
Endfor
Endif
=Fclose(gnerrfile ) && Close file
Endif
Endif
Function credbf2sql
Parameter fname,litxtsql,sqlfname
litxtsql=Iif(Empty(litxtsql),.F.,.T.)
If Empty(sqlfname)
sqlfname=fname
Endif
Private nfields, Afields, Lcf
If Used(m.fname)
Use In (m.fname)
Endif
Use (m.fname)
nfields = Afields(aflds)
lcsorgu='create table '+m.sqlfname+'('
lcsorgu1=''
lcsorgu2=''
For Lcf = 1 To nfields
If Upper(aflds(Lcf, 1))='GUID' Or Upper(aflds(Lcf, 1))='SIRANO'
Else
lcbaslik=aflds(Lcf, 1)
Do Case
Case lcbaslik=='NOT'
lcbaslik='NOT1'
Case lcbaslik=='INDEX'
lcbaslik='INDEX1'
Endcase
lcsorgu1=lcsorgu1+lcbaslik
lctipi=aflds(Lcf, 2)
Do Case
Case lctipi='C'
lcsorgu1=lcsorgu1+' [char]'
Case lctipi='D' Or lctipi='T'
lcsorgu1=lcsorgu1+' [datetime]'
Case lctipi='I' Or lctipi='L'
lcsorgu1=lcsorgu1+' [int]'
Case lctipi='M'
lcsorgu1=lcsorgu1+' [text]'
Case lctipi='N'
lcsorgu1=lcsorgu1+' [numeric]'
Endcase
If aflds(Lcf, 2)='N' .And. aflds(Lcf, 4)=>0
lcsorgu1=lcsorgu1+' ('+Alltrim(Str(aflds(Lcf, 3), 6))+','+Ltrim(Str(aflds(Lcf, 4)))+')'
Else
If lctipi='T' Or lctipi='D' Or lctipi='I' Or lctipi='M' Or lctipi='L'
Else
lcsorgu1=lcsorgu1+'('+Alltrim(Str(aflds(Lcf, 3), 6))+')'
Endif
Endif
lcsorgu1=Lower(lcsorgu1)+' NULL,'+Chr(13)
Endif
Endfor
lcsorgu1=lcsorgu1+' [guid] [uniqueidentifier] NOT NULL CONSTRAINT [DF_'+Alltrim(sqlfname)+'_guid] DEFAULT (newid()),'
lcsorgu1=lcsorgu1+' [sirano] [int] IDENTITY(1,1) NOT NULL,'
lcsorgu1=lcsorgu1+' CONSTRAINT [PK_'+Alltrim(sqlfname)+'] PRIMARY KEY CLUSTERED'
TEXT TO Lcsorgu2 NOSHOW PRETEXT 7 TEXTMERGE
( [guid] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
ENDTEXT
lcsorgu=lcsorgu+lcsorgu1+lcsorgu2+' ) ON [PRIMARY] '
Use
If litxtsql=.T.
If File('NesSQLData.txt') && Does file exist?
gnerrfile = Fcreate('NesSQLData.txt') && If not create it
* gnErrFile = Fopen('NesSQLData.txt',12) && If so, open read/write
Else
gnerrfile = Fcreate('NesSQLData.txt') && If not create it
Endif
If gnerrfile < 0 && Check for error opening file
Wait 'Cannot open or create output file' Window Nowait
Else && If no error, write to file
=Fwrite(gnerrfile , lcsorgu)
Endif
=Fclose(gnerrfile ) && Close file
If gnerrfile > 0
Modify File nessqldata.txt Nowait && Open file in edit window
Endif
Else
** bilgi yaz.
If File('errors.txt') && Does file exist?
gnerrfile = Fopen('errors.txt',2) && If so, open read/write
x1=Fseek(gnerrfile,0,2)
Else
gnerrfile = Fcreate('errors.txt') && If not create it
x1=Fseek(gnerrfile,0,2)
Endif
If gnerrfile > 0 && Check for error opening file
=Fwrite(gnerrfile ,m.fname+Ttoc(Datetime())+ Chr(13))
Endif
=Fclose(gnerrfile ) && Close file
lcokkk=MYSQLEXEC(baglan(),m.lcsorgu)
Wait Window m.fname+' Oluşturuldu.' Nowa
Endif
If Used(m.fname)
Use In (m.fname)
Endif
If lcokkk=.T.
Return=.T.
Else
Return=.F.
Endif
Endfunc |