_Chris_ Posted September 22, 2006 Share Posted September 22, 2006 (edited) expandcollapse popup#include <GUIConstants.au3> #include <Process.au3> #Region ### START Koda GUI section ### Form=c:\documents and settings\target tracker\desktop\koda_1.6.0.0\forms\attach.kxf $Main = GUICreate("AForm1", 373, 177, 193, 115) $DBNAME = GUICtrlCreateInput("", 168, 56, 161, 21) $MDFPATH = GUICtrlCreateInput("", 168, 80, 161, 21) $LDFPATH = GUICtrlCreateInput("", 168, 104, 161, 21) $Run = GUICtrlCreateButton("Run", 272, 136, 81, 25, 0) $AttachDB = GUICtrlCreateLabel("Attach Database:", 8, 8, 87, 17) $DBNAMEL = GUICtrlCreateLabel("Database Name:", 24, 56, 84, 17) $DBL = GUICtrlCreateLabel("Database File Location:", 24, 80, 116, 17) $LOGL = GUICtrlCreateLabel("Log file Location:", 24, 104, 85, 17) $LogButton = GUICtrlCreateButton("...", 336, 104, 19, 17, 0) $DBButton = GUICtrlCreateButton("...", 336, 80, 19, 17, 0) $PCNAME = GUICtrlCreateInput("", 168, 32, 161, 21) $SQL = GUICtrlCreateLabel("SQL Sever Name:", 22, 31, 90, 17) GUISetState(@SW_SHOW) GUICtrlSetData ($PCNAME,@ComputerName) #EndRegion ### END Koda GUI section ### DO $Msg = GUIGetMsg() Select Case $Msg = $LogButton $LF = FileSaveDialog ("Select Database Log File", "C:\MSDE2000A\Data_Folder\", "SQL Database Log Files (*.ldf)", 1 ) GUICtrlSetData ($LDFPATH,$LF) Case $Msg = $DBButton $DB = FileSaveDialog ("Select Database File", "C:\MSDE2000A\Data_Folder\", "SQL Database Files (*.mdf)", 1 ) GUICtrlSetData ($MDFPATH,$DB) Case $msg = $RUN $PC = GuiCtrlRead($PCNAME) $DBNAMEFIELD = GuiCtrlRead($DBNAME) $MDF = GuiCtrlRead($MDFPATH) $LDF = GuiCtrlRead($LDFPATH) $file = FileOpen("test.txt", 2) FileWrite($file, '"'&"osql -U sa -P "&'"admin01user" -S '&$PC&' -Q "sp_attach_db '&"'"&$DBNAMEFIELD&"', '"&$MDF&"', '"& $LDF&"'"&'"') FileClose($file) EndSelect Until $Msg = $Gui_Event_Close I cant seem to get this to write the information into the text file, it failes when i use the browser buttons, it puts the location i choose in the text boxes but dosent paste it into the text file? HELP!! (larry) editted to make readable. Edited September 22, 2006 by Larry Link to comment Share on other sites More sharing options...
_Chris_ Posted September 22, 2006 Author Share Posted September 22, 2006 What did you edit Larry? No ideas on how to fix it? Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 22, 2006 Share Posted September 22, 2006 (edited) CODE#include <GUIConstants.au3> #include <Process.au3> #Region ### START Koda GUI section ### Form=c:\documents and settings\target tracker\desktop\koda_1.6.0.0\forms\attach.kxf $Main = GUICreate("AForm1", 373, 177, 193, 115) $DBNAME = GUICtrlCreateInput("", 168, 56, 161, 21) $MDFPATH = GUICtrlCreateInput("", 168, 80, 161, 21) $LDFPATH = GUICtrlCreateInput("", 168, 104, 161, 21) $Run = GUICtrlCreateButton("Run", 272, 136, 81, 25, 0) $AttachDB = GUICtrlCreateLabel("Attach Database:", 8, 8, 87, 17) $DBNAMEL = GUICtrlCreateLabel("Database Name:", 24, 56, 84, 17) $DBL = GUICtrlCreateLabel("Database File Location:", 24, 80, 116, 17) $LOGL = GUICtrlCreateLabel("Log file Location:", 24, 104, 85, 17) $LogButton = GUICtrlCreateButton("...", 336, 104, 19, 17, 0) $DBButton = GUICtrlCreateButton("...", 336, 80, 19, 17, 0) $PCNAME = GUICtrlCreateInput("", 168, 32, 161, 21) $SQL = GUICtrlCreateLabel("SQL Sever Name:", 22, 31, 90, 17) GUISetState(@SW_SHOW) GUICtrlSetData ($PCNAME,@ComputerName) #EndRegion ### END Koda GUI section ### DO $Msg = GUIGetMsg() Select Case $Msg = $LogButton $LF = FileSaveDialog ("Select Database Log File", "C:\MSDE2000A\Data_Folder\", "SQL Database Log Files (*.ldf)", 1 ) GUICtrlSetData ($LDFPATH,$LF) Case $Msg = $DBButton $DB = FileSaveDialog ("Select Database File", "C:\MSDE2000A\Data_Folder\", "SQL Database Files (*.mdf)", 1 ) GUICtrlSetData ($MDFPATH,$DB) Case $msg = $RUN $PC = GuiCtrlRead($PCNAME) $DBNAMEFIELD = GuiCtrlRead($DBNAME) $MDF = GuiCtrlRead($MDFPATH) $LDF = GuiCtrlRead($LDFPATH) $file = FileOpen("test.txt", 2) FileWrite($file, '"'&"osql -U sa -P "&'"admin01user" -S '&$PC&' -Q "sp_attach_db '&"'"&$DBNAMEFIELD&"', '"&$MDF&"', '"& $LDF&"'"&'"') FileClose($file) EndSelect Until $Msg = $Gui_Event_Close I cant seem to get this to write the information into the text file, it failes when i use the browser buttons, it puts the location i choose in the text boxes but dosent paste it into the text file? HELP!! (larry) editted to make readable. Keying off what Larry said above, you can double check it by putting in a debug message box: ; FileWrite($file, '"'&"osql -U sa -P "&'"admin01user" -S '&$PC&' -Q "sp_attach_db '&"'"&$DBNAMEFIELD&"', '"&$MDF&"', '"& $LDF&"'"&'"') $WriteLine = '"'&"osql -U sa -P "&'"admin01user" -S '&$PC&' -Q "sp_attach_db '&"'"&$DBNAMEFIELD&"', '"&$MDF&"', '"& $LDF&"'"&'"' MsgBox(64, "Debug", "$WriteLine = " & $WriteLine) FileWrite($file, $WriteLine) FileClose($file) See if that pops the write line you expect... Edited September 22, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
_Chris_ Posted September 22, 2006 Author Share Posted September 22, 2006 Thanks ill try that Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now