Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2007, 09:46 AM
Authorized User
 
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default Database Connection / Login help needed

Any help you can provide will be greatly appreciated.
I am attempting to get my database connection/login working.
I am using SQL 2K5 with VB 2K5.

Currently, I'm doing all the development on my local machine, while waiting for the main Windows 2K3 server to be built, so I can put the SQL server there. So, things will change in a week or so, but I need to get it working locally first.

I will be using mixed mode authentication.

Anyway,
what I am having problems figuring out is how to parse My.User so that I only pick up the information after the '\' (the user name) - I don't want the domain name (or machine name)! (For the moment, all the user accounts on the server have the same password - not good, but the current "system/network" administrator does things easy, not necessarily secure, so I am following suit.)

At some point, I hope to use integrated authentication after the domain is totally set up, but that is in the future.

Can any one help point me in the right direction?

 
Old April 6th, 2007, 12:46 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You can use InStrRev("....", "\") to find the last backslash's position, then grab all after that.
Code:
    Dim i      As Integer
    Dim MyUser As String

    i = InStrRev(My.User, "\")
    MyUser = Mid$(My.User, i)
 
Old April 6th, 2007, 01:15 PM
Authorized User
 
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default

Brian,
Thanks for the response.
I added the code and got this error message.
'Microsoft.VisualBasic.ApplicationServices.User' cannot be converted to 'String'.

Did I miss something?

Karen

 
Old April 6th, 2007, 04:10 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Sorry...
Code:
    Dim i      As Integer
    Dim MyUser As String

    i = InStrRev(My.User.ToString(), "\")
    MyUser = Mid$(My.User.ToString(), i)
 
Old April 9th, 2007, 10:26 AM
Authorized User
 
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks, that fixed it!

Karen






Similar Threads
Thread Thread Starter Forum Replies Last Post
RMA database needed Mitch Access 1 February 26th, 2008 02:29 PM
Replacing Database connection upon login rsasuncion1010 ASP.NET 2.0 Basics 0 March 28th, 2007 01:09 AM
Data base connection string needed pramos.21d ADO.NET 3 March 8th, 2005 01:21 PM
Login Failed: Not assoc. w/ Trusted Connection xgbnow Pro VB Databases 4 March 4th, 2004 11:52 AM
Sample database needed smokin Access 12 March 1st, 2004 12:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.