Page 1 of 1 1
Topic Options
#198383 - 2010-04-09 09:57 PM DBConnOpen
que Offline
Just in Town

Registered: 2010-04-09
Posts: 2
Loc: MD, US
Hello,

i trying to convert a SQL server DBConnOpen to MS access.mdb but everytime i test the DBConnOpen connection string im getting
ERROR: expected ')'
any insight is appreciated.

thanks

$objConn = DBConnOpen('DRIVER={Microsoft Access Driver (*.mdb)}; UID=; PWD=; DBQ=shares.mdb')
$recordset = DBGetRecordset($objConn,"SELECT securitygroup, sharename, sharepath, comment FROM shares")
if @error
"error occured: @serror (@error)"
else

for $counter=0 to ubound($recordset)
$GroupName = +$recordset[$counter,0]
$ShareName = +$recordset[$counter,1]
$SharePath = +$recordset[$counter,2]
$Comment = +$recordset[$counter,3]


$deskfolder="%userprofile%\desktop\"
$profdesk=$deskfolder + '$ShareName' + '.lnk'

if fnIngroupAD($GroupName)=1
$add=AddToMyNetworkPlaces($ShareName,$SharePath,$Comment)=1
WshShortCut("$profdesk","$SharePath",,"")
endif

next

$ObjCl = DBConnClose($objConn)

:exit1

Top
#198384 - 2010-04-10 01:09 AM Re: DBConnOpen [Re: que]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Please try searching the board as this has been discussed a few times.

Also as a resource: http://www.connectionstrings.com/

Thanks.

Top
#198463 - 2010-04-28 08:31 AM Re: DBConnOpen [Re: NTDOC]
que Offline
Just in Town

Registered: 2010-04-09
Posts: 2
Loc: MD, US
 Code:
<%
Dim strConnString
' Sample access OLEDB CONN String.

strConnString = "Provider=SQLOLEDB;Data Source=localhost;" _
	& "Initial Catalog=db;User Id=ddd;Password=ddd;" _
	& "Connect Timeout=15;Network Library=dbmssocn;"


Const DATE_DELIMITER = "'"


Dim cnnFormToDB       ' CONN object
Dim strSQL            ' String in which to build our SQL command
Dim lngRecsAffected   ' # of records affected... just informational


Dim security1
Dim sharename1
Dim sharepath1
Dim username1

Dim strErrorMsg       ' Holds error message if we catch any problems.



If Request.Form("action") <> "Save Form Data" Then
	' Show the form
	%>
	<form action="<%= Request.ServerVariables ("insert.asp") %>" method="post">
	<input type="hidden" name="action" value="Save Form Data" />
	<table border="0">
	<tr>
		<td align="right"><strong>security:</strong></td>
		<td align="left"><input type="text" name="security"  /></td>
	</tr>
	<tr>
		<td align="right"><strong>sharename:</strong></td>
		<td align="left"><input type="text" name="sharename" /></td>
	</tr>
	<tr>
		<td align="right"><strong>sharepath:</strong></td>
		<td align="left"><input type="text" name="sharepath" /></td>
	</tr>
	<tr>
		<td align="right"><strong>username:</strong></td>
		<td align="left"><input type="text" name="username" /></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>
			<input type="reset" value="Clear" />
			<input type="submit" value="Save" />
		</td>
	</tr>
	</table>
	</form>
	<%
Else

	security1 = Request.Form("security")
	sharename1 = Request.Form("sharename")
	sharepath1 = Request.Form("sharepath")
	username1 = Request.Form("username")



		' Open connection to the DB
		Set cnnFormToDB = Server.CreateObject("ADODB.Connection")
		cnnFormToDB.Open strConnString

		' Build our SQL String
		strSQL = ""
		strSQL = strSQL & "INSERT INTO logon "
		strSQL = strSQL & "(security, sharename, sharepath, username) " & vbCrLf
		strSQL = strSQL & "VALUES ("
		strSQL = strSQL & "'" & security1 & "'"
		strSQL = strSQL & ", "
		strSQL = strSQL & "'" & sharename1 & "'"
		strSQL = strSQL & ", "
		strSQL = strSQL & "'" & sharepath1 & "'"
		strSQL = strSQL & ", "
		strSQL = strSQL & "'" & username1 & "'"
		strSQL = strSQL & ");"

	
		cnnFormToDB.Execute strSQL, lngRecsAffected, adCmdText Or adExecuteNoRecords

		
		cnnFormToDB.Close
		Set cnnFormToDB = Nothing
		
		
		%>
		<h2>Thanks for submitting your information to us!</h2>
		
		<p>
		<strong>The resulting SQL statement was:</strong>
		<pre><%= strSQL %></pre>
		</p>
		
		<p>
		<strong>Number of records affected:</strong> <%= lngRecsAffected %>
		</p>
<%	
	
End If
%>


*****************************************************

<%

Dim strURL     
               

Dim cnnSearch  
Dim rstSearch  


Dim strSQL     
Dim strSearch


strURL = Request.ServerVariables("URL")

strSearch = Request.QueryString("search")


%>
<p>Search username login in to domain</p>
<form action="<%= strURL %>" method="get">
<input name="search" value="<%= strSearch %>" />
<input type="submit" />
</form>

<%
If strSearch <> "" Then


	Set cnnSearch = Server.CreateObject("ADODB.Connection")

	
	cnnSearch.Open "Provider=SQLOLEDB;Data Source=localhost;" _
		& "Initial Catalog=db;User Id=ddd;Password=ddd;" _
		& "Connect Timeout=15;Network Library=dbmssocn;"

	strSQL = "SELECT username, sharename, sharepath " _
		& "FROM logon " _
		& "WHERE username LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
		& "ORDER BY sharename;"

	Set rstSearch = cnnSearch.Execute(strSQL)

	%>
	<table border="1">
	<tr>
	<th>userName</th>
	<th>sharepath</th>
	<th>sharename</th>
	</tr>
	<%
	Do While Not rstSearch.EOF
		%>
		<tr>
		<td><%= rstSearch.Fields("username").Value %> </td>
		<td><%= rstSearch.Fields("sharepath").Value %></td>
		<td><%= rstSearch.Fields("sharename").Value %></td>
		</tr>
		<%

		rstSearch.MoveNext
	Loop
	%>
	</table>
	<%
	
	rstSearch.Close
	Set rstSearch = Nothing
	cnnSearch.Close
	Set cnnSearch = Nothing
End If


%>


Edited by Mart (2010-04-28 08:56 AM)
Edit Reason: Added code tags

Top
#198466 - 2010-04-28 10:01 AM Re: DBConnOpen [Re: que]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Are you including the DBConnOpen(), DBGetRecordSet(), DBConnClose() fnIngroupAD() and WshShortCut() functions in your script?

The following is not valid KiXtart syntax, I think that you want to remove the "+" sign:
 Code:
$GroupName = +$recordset[$counter,0]

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.038 seconds in which 0.018 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org