Hi Pros,
I am new to VB and I was asked to research about a .vbs extension file.
I am supposed to use Notepad to write my codes and save it in a *.vbs extension.
I would like to know if I can connect to the database using this method?

Dani AI

Generated

Short answer: yes — a .vbs file can run standalone under Windows Script Host (WSH) and open database connections using ADO/ODBC/OLE DB. That covers the scenario asked about and complements 's note about server-side ASP use. 's XP issues point to a class of environment/driver problems that are common; see diagnostics below.

Practical steps and checks:

  • Run the script from a console so errors are visible: cscript //nologo script.vbs.
  • Use an ADO connection object (for example, via CreateObject("ADODB.Connection")) and the appropriate provider/driver for the target DB (SQL Server, Jet/ACE for Access, or an ODBC DSN).
  • Prefer System DSNs for scripts run by services or other accounts; User DSNs are tied to the logged-in user.
  • Verify the right client components are installed (MDAC/ODBC drivers or Access Database Engine) and match the process bitness: Jet OLEDB.4.0 does not load in a 64-bit process, so either install the correct ACE driver or run the 32-bit host.

Common failure modes:

  • Missing or wrong provider/driver, 32-bit vs 64-bit mismatch, DSN scope, insufficient permissions, WSH disabled by policy/registry, or antivirus/group policy blocking .vbs. To isolate, run a minimal connect-from-console, capture the exact error text, and check installed ODBC/OLE DB providers in Administrative Tools.

Security note: avoid hardcoding credentials in scripts; prefer Integrated Security where possible and restrict file permissions.

Recommended Answers

All 3 Replies

sort of.

You can using VBS inside an ASP page on a web server, but i dont about standalone

Thanks. But I need it to be a standalone.

Yes you can, but I've been having some intermittant problems myself depending on OS and some other settings.

Check this out to see my code:
http://www.daniweb.com/forums/thread99052.html

I connect fine with windows 2000, but there is something wrong client-side on XP

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.