|
-
Feb 12th, 2012, 01:35 PM
#1
Thread Starter
New Member
VB6 MSSQL Windows Authentication & Select Count in TextBox
All,
I am looking for an example of the windows authenticated connection to an MSSQL DB and a select count statement in a textbox in my form.
I have this connection string:
Code:
Dim SQLCon As ADODB.Connection
Set SQLCon = New ADODB.Connection
With SQLCon
Provider=SQLOLEDB.1;Integrated Security=True;Initial Catalog=MY DATABASE;Data Source=MY SERVER;Persyst Security Info=False;Command Properties='Command Time Out=45'"
End With
Can I simply just paste this into my form_onload? Also how to I reference this connection when I then go to add my SQL query to textboxes etc?
Does anyone have any example code they would be willing to share or take the time to explain this to me.
Any replice will be much appreciated.
Thanks,
Ben.
Last edited by whitelockben; Feb 12th, 2012 at 01:39 PM.
-
Feb 13th, 2012, 05:24 AM
#2
Frenzied Member
Re: VB6 MSSQL Windows Authentication & Select Count in TextBox
Can I simply just paste this into my form_onload? Also how to I reference this connection when I then go to add my SQL query to textboxes etc?
Does anyone have any example code they would be willing to share or take the time to explain this to me.
Any replice will be much appreciated.
i am not sure what you want to achieve .but try the following way .
Code:
Dim SQLCon As ADODB.Connection
dim rs as New adodb.recordset
Set SQLCon = New ADODB.Connection
With SQLCon
Provider=SQLOLEDB.1;Integrated Security=True;Initial Catalog=MY DATABASE;Data Source=MY SERVER;Persyst Security Info=False;Command Properties='Command Time Out=45'"
.open
End With
Now
rs.open sqlcon,con,adopendynamic,adlockoptimistic
if rs.state=adstateopen then
---if you want to refere database fields and pull into the textboxes .just do the following way
txtname.text=rs.fields("0")
Txtaddress.text=rs.fields("1")
end if
Last edited by firoz.raj; Feb 13th, 2012 at 05:27 AM.
-
Feb 13th, 2012, 07:20 AM
#3
Thread Starter
New Member
Re: VB6 MSSQL Windows Authentication & Select Count in TextBox
 Originally Posted by firoz.raj
i am not sure what you want to achieve .but try the following way .
Code:
Dim SQLCon As ADODB.Connection
dim rs as New adodb.recordset
Set SQLCon = New ADODB.Connection
With SQLCon
Provider=SQLOLEDB.1;Integrated Security=True;Initial Catalog=MY DATABASE;Data Source=MY SERVER;Persyst Security Info=False;Command Properties='Command Time Out=45'"
.open
End With
Now
rs.open sqlcon,con,adopendynamic,adlockoptimistic
if rs.state=adstateopen then
---if you want to refere database fields and pull into the textboxes .just do the following way
txtname.text=rs.fields("0")
Txtaddress.text=rs.fields("1")
end if

Thank you for the reply! What I want to do is add some select counts to textboxes. Do you know how I would do this please? Can I just use the datasource field of the textbox once I have declared my connection?
Ben
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|