Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Field Names

Status
Not open for further replies.

DANZIG

Technical User
Mar 8, 2001
142
US
Hello,
I'm trying to export field names fro tables to a notepad document to avoid having to type them over and over for various queries I'v got some of the code below but I'm missing something.

Code:
Set oWshShell = WScript.CreateObject("WScript.Shell")
	oWshShell.Run "notepad", 9
	WScript.Sleep 500
	
	Dim objConn
	Set objConn=CreateObject("ADODB.Connection")
		ConnectSTR = "driver=SQL Server;server=SQLSERVER01;uid=SQLUSER;pwd=SQLPASS;database=SOMEDB;"
		objConn.Open ConnectSTR
		set oRsFields = CreateObject("ADODB.Recordset")
			oRsFields.Open objConn
				For Each oField in oRsFields
					WshShell.SendKeys oRsFields.Name
					WshShell.SendKeys "{ENTER}"
				Next
			oRsFields.Close
		set oRsFields = Nothing

Any ideas?

Thanks in advance


Thanks, Danzig
 
Answered my own question asked too soon 8)
Code:
Set oWshShell = WScript.CreateObject("WScript.Shell")
	oWshShell.Run "notepad", 9
	WScript.Sleep 500
	
	Dim objConn
	Set objConn=CreateObject("ADODB.Connection")
		ConnectSTR = "driver=SQL Server;server=SQLSERVER01;uid=SQLUSER;pwd=SQLPASS;database=SOMEDB;"
		objConn.Open ConnectSTR
		str_SQL = "Select * from Some_Table"
		set oRsFields = CreateObject("ADODB.Recordset")
			oRsFields.Open str_SQL, objConn
				For Each oField in oRsFields.Fields
					oWshShell.SendKeys oField.Name
					oWshShell.SendKeys "{ENTER}"
				Next
			oRsFields.Close
		set oRsFields = Nothing


Thanks, Danzig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top