Link to home
Create AccountLog in
Avatar of billmurp

asked on

need TSQL help file for VB6 & SQL Server 2005 ???

Does anybody know how to get or where do I get it from:
TSQL help file on the commands I use with VB6 and Sql Server 2005 ????
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Did you install SQL Server 2005 Books Online?  What version of SQL Server did you install?

Avatar of chapmandew
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of billmurp


I have books online (sept'2007) and it tells you nothing in there
Are you trying to figure out how to connect to the database through VB?
i've tried it with the following code and I get the following error message:

Rub-time error '-2147217887 (80040e21):
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
I fixed the Registry OLEDB_SERVICES like they said, & it does not work does anybody know the complete format of all options with the .OPEN string statement to connect to SQL Server 2005 on the (local) host

Private Sub Command1_Click()

    Dim objCon As ADODB.Connection
    Dim objCom As ADODB.Command
    Dim objPara As ADODB.Parameter
    Dim objpara2 As ADODB.Parameter
    Dim objRS As ADODB.Recordset
    Dim k As Integer
    Dim strdbpath As String
    Set objCon = New ADODB.Connection
    Set objCom = New ADODB.Command
    'Creating the DB connection string
    'Please change the below connection string as per your server and
    'database being used.
    strdbpath = "C:\program files\microsoft SQL server\mssql.1\mssql\data\customerorders.mdf"
    objCon.ConnectionString = "Driver={SQL Native Client}; Server=(local); AttachDbFilename=" & strdbpath & "; Trusted_Connection=Yes; Integrated Security=SSPI; MARS_Connection=yes;"
    'Opening the connection
    objCon.Open objCon.ConnectionString

The error happens on the above statement
You're connecting to it incorrectly.  You're trying to connect to the sql server like you do an access database, and you can't do it that way.

Your connection string should look like this...just swap out with variables

Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
i put the following code in:

  objCon.ConnectionString = "Driver={SQL Native Client};Server=(local);Database=" & strdbpath & ";Uid=" & "sa" & ";Pwd=;Trusted_Connection=Yes;"

and i'm now getting error: can not access the database login failed ????
you probably need to give it a password, or a valid sql server account name and pwd.
how in SQL server 2005 using "SQL Server Management Studio" do I give myself a userid and password to access tne database I am after
i'm having trouble with  "SQL Server Management Studio", in
object explorer on the left side - I highlight my database and issue a new query & i put in
Create Login username password='xxxxxx';
the command works and when i execute my program in VB
I get the error can't open the database requested by the login ???
you have to create a user in the specific database as well....

or just make the login you created a sysadmin
let me ask you something & if you don't want to answer
I can understand why - are you from the northeast in the United States
southern indiana/ lousiville, ky

do you mind if i call you - i think i can get this resolved very quickly or you can call me - my name is bill murphy from Long Island, NY (631) 751-5881
Sorry....that type of exchange isn't supposed to go on on here...

...and I don't do conversations or personal help unless I am paid.  :)

I think you are on the right track w/ your code...just work on it.

how much do you want for an hour's worth of work

let me give you a liitle understanding of my background. I'm probably much older than you - I am 54 yrs.old, married and have 4 kids. I've been in my own business since 1983.
my website (which is not too good) is
check on the home page at the bottom the 2 systems I deveoped back in 1985 and 1994 wich was using gwbasic at the time
and then I converted to Visual basic in the 90's. I know VB quite well, but I now have a client who wants me to do work
with his database of around 400 tables that is used with VB6 and TSQL with the SQL Server 2005. I have to give him an answer by Friday on whether or not I want to do this or not.
I know the TSL language using it on the Server but I don't know how to use it yet with VB6 - so when you sent me the sample code for Access the other day - I already know that stuff and thats why I was not interested. All I need you to do which should take no more than 20-35 minutes of your time is get me to hook up with the database and once I'm in I know how to execute the TSQL statements and use them. Trust me you will get paid.

Bill Murphy