Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > How do I add password to DB via code?


Reply
 
Thread Tools Display Modes
  #1  
Old 08-24-2004, 11:46 PM
Cert Cert is offline
Contributor
 
Join Date: Aug 2002
Posts: 515
Default How do I add password to DB via code?


I'm still very inexperienced with ADO, and with my latest project that I'm working on I want the database to have a password; however I am using the code from this thread http://www.xtremevbtalk.com/showthre...threadid=20002 to create the database at runtime through code (Thanks Thinking & usetheforce2), so my question is how/what do I modify in order to give the database a password?

Here's the code from the sample above so that you don't have to download it..

Code:
Public Sub CreateDataBase() Dim objcat As adox.Catalog Dim objMyTable As New adox.Table Set objcat = New adox.Catalog objcat.Create strConnection objcat.ActiveConnection = strConnection With objMyTable .Name = "MyTable" .Columns.Append "Name", adVarWChar, 20 .Columns.Append "Address", adVarWChar, 50 .Columns.Append "City", adVarWChar, 50 .Columns.Append "ST", adVarWChar, 20 .Columns.Append "PostalCode", adVarWChar, 20 .Keys.Append "PrimaryKey", adKeyPrimary, "Name" End With objcat.Tables.Append objMyTable Set objMyTable = Nothing Set objcat = Nothing End Sub

Thanks.
Reply With Quote
  #2  
Old 08-24-2004, 11:50 PM
Cert Cert is offline
Contributor
 
Join Date: Aug 2002
Posts: 515
Default

Nevermind, I should have tried to use my brain before posting.

I saw here
Code:
objcat.Create strConnection objcat.ActiveConnection = strConnection
that it was using the connection string that was being created in Form_Load, so I modified the connection string to include the password, and viola the database was created with that password.

Hope this helps someone else...

Last edited by Cert; 08-24-2004 at 11:51 PM. Reason: typo..
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->