Hi,
I am very new to VB, and I have just has a DB project thrown at me.
I need to connect to a VB database, I can create the connection in the data
environment, but I have not got a clue how to use the connection in my
code...
I have a VB 6 training kit, but I cannot get the example code to run without
getting a message to the gist of "Illegal use of New function"
I try to create an SQL string that I want to submit to my MS SQL server
running on my remote server. This functions, and the SQL string is correct.
I just cannot figure a way to connect, to the server and submit my query in
VB. I'm using VB 6 under Windows 98 SE and Windows 2000 Pro. All networking
is functionning, and sql server is up and answering via Query Analyzer.
All constructive help appreciated - I am getting to the point of sacrificing
my boss to the god of computing for lack of support...
Cordially,
Daniel Page
My code below:
Private Sub Command1_Click()
Set cnHost = New Connection
Set rsHostss = New Recordset
uristring = hostname.Text
'The value of the entered text is in uristring.
sql = "select ip from hosts where uri = """
sql = sql & uristring
sql = sql & """;"
'Chuck the query at the database
cnHost.Provider = "SQLOLEDB"
cnHost.ConnectionString = "User ID=hostuser;" & "Password=huser;" & "Data
Source=HISTDATA;" & "Initial Catalog=Hosts"
cnHost.Open
cnHost.CommandText = uristring
ipaddress.Text = rsHostss!ip
Print "Query submitted"