Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Mon Nov 23, 2009 2:25 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ]  Bookmark and Share
Author Message
 Post subject: Collect data from table and write to a file
PostPosted: Mon Mar 09, 2009 12:50 pm 
Offline

Joined: Tue Dec 18, 2007 11:51 am
Posts: 1
Hi,
I need to do a vbscript or a VB that connect to a database, execute a sql statement and send the output to a file. I have the done something so far, but I can't finish it. Can someone help me?

Dim cmd
Dim rs
Dim params
Dim param
Dim ArgObj, sunumber

Set ArgObj = WScript.Arguments
set cn=createobject("ADODB.Connection")
set cmd=createobject("ADODB.Command")
set rs=createobject("ADODB.Recordset")

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("%comspec% /c <Console Command>")

cn.Provider = "SQLOLEDB"
cn.Open "Data Source = xpto", "User", "User"

Set cmd.ActiveConnection = cn
cmd.CommandText = "SELECT (*) FROM table"


Top
 Profile  
 
 Post subject: Re: Collect data from table and write to a file
PostPosted: Mon Mar 09, 2009 7:15 pm 
Offline

Joined: Mon Mar 09, 2009 1:52 am
Posts: 7
Private Sub DisplayDepartments()
On Error GoTo MeError
Dim iSize(5000) As Integer
Dim StrSql As String
Set nDepartment = New Collection
'
' Query to read all entries from table called Department
'
StrSql = "SELECT * FROM Department order by DepartmentID"
'
' Open Database
'
Set DB = OpenDatabase(DatabaseName)
Set qdfLocal = DB.CreateQueryDef("")
qdfLocal.sql = StrSql
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim iRowloc As Integer
Dim cMsg As String
iRowloc = 1
Set rstTopFive = qdfLocal.OpenRecordset()
'
' j=Number of records
'
j = rstTopFive.Fields.Count
If j = 0 Then GoTo MeClose
iMax = j - 1
'
' Read all the Fields Names
'
cMsg = ""
For i = 0 To j - 1
k = Len(rstTopFive.Fields(i).Name)
cMsg = cMsg & rstTopFive.Fields(i).Name '& Space(iSize(i) - k)
'iSize(i) = Len(rstTopFive.Fields(i).Name)
If i < j - 1 Then cMsg = cMsg & Chr(9)
' LblFld(i).Caption = rstTopFive.Fields(i).Name
Next
FlexDepartments.Clear
FlexDepartments.Rows = 1
ComUserDepartment.Clear
cMsg = cMsg & " "
FlexDepartments.FormatString = cMsg

'
' Read all the Entries
'
For i = 0 To 49
DepartmentName(i) = "?"
Next
With rstTopFive
Do While Not .EOF
cMsg = ""
Set cDepartment = New clsDepartment
For i = 0 To j - 1
cMsg = cMsg & rstTopFive.Fields(i)
If i < j - 1 Then cMsg = cMsg & Chr(9)
Next

FlexDepartments.AddItem cMsg, iRowloc
.MoveNext
Loop
.Close
End With
MeClose:
DB.Close

Exit Sub
'
' For Error - close database
'
MeError:
MsgBox Error$()
DB.Close
End Sub


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley