EDN Admin
Well-known member
Greetings, world of VBasicers!
Im trying to create a VBasic executable to read a SQL server database and produce a mailing list. I have the SQL routine working fine and had set it up as a stored procedure, but Ive just discovered the manager Ive written this for is an Access-type
and does not have SQL Server installed on her machine. So, I figured Id make a front end in VBasic.
This is my first foray into accessing SQL with VB and Im not entirely sure this is the right forum, so, please, bear with me.
The first issue is the connection. The one I found online goes like this;
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim con <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlConnection
con.ConnectionString = <span style="color:#A31515; "Data Source=mySQLServer;User ID=Username;Password=myPass;"
con.Open()
[/code]
Now, I dont want to enter my user ID or password. One, because of security; two, because I need it to authenticate under her - or, whomever will use the app - credentials.
So, the first question is; am I able to set up the connection string to use Windows authentication, rather than hard-wired user info?
Now, the second issue. From what Ive found, its easy enough to send a parameter to the stored procedure; the report date. The SP manipulates that value and then returns a list of names, addresses, etc. (about 8 or 9 fields). But, from what I see in the
code I found, the example only seems to return a single value, whereas I need multiple records of many columns each. Of course, the columns are identical for each record, but still, a lot of them - typically, over a thousand and not a set number.
The code I found to retrieve the data is this;
<div style="color:Black;background-color:White; <pre>
sql.ExecuteNonQuery();
<span style="color:Blue; string firstname=(<span style="color:Blue; string) sql.Parameters[<span style="color:#A31515; "@firstname"].Value;
[/code]
As can be seen, it only grabs one field.
If anyone out there has a template on how to retrieve more than one field for more than one record, I can - probably - just go from there.
Many thanks in advance for any assistance!
View the full article
Im trying to create a VBasic executable to read a SQL server database and produce a mailing list. I have the SQL routine working fine and had set it up as a stored procedure, but Ive just discovered the manager Ive written this for is an Access-type
and does not have SQL Server installed on her machine. So, I figured Id make a front end in VBasic.
This is my first foray into accessing SQL with VB and Im not entirely sure this is the right forum, so, please, bear with me.
The first issue is the connection. The one I found online goes like this;
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim con <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlConnection
con.ConnectionString = <span style="color:#A31515; "Data Source=mySQLServer;User ID=Username;Password=myPass;"
con.Open()
[/code]
Now, I dont want to enter my user ID or password. One, because of security; two, because I need it to authenticate under her - or, whomever will use the app - credentials.
So, the first question is; am I able to set up the connection string to use Windows authentication, rather than hard-wired user info?
Now, the second issue. From what Ive found, its easy enough to send a parameter to the stored procedure; the report date. The SP manipulates that value and then returns a list of names, addresses, etc. (about 8 or 9 fields). But, from what I see in the
code I found, the example only seems to return a single value, whereas I need multiple records of many columns each. Of course, the columns are identical for each record, but still, a lot of them - typically, over a thousand and not a set number.
The code I found to retrieve the data is this;
<div style="color:Black;background-color:White; <pre>
sql.ExecuteNonQuery();
<span style="color:Blue; string firstname=(<span style="color:Blue; string) sql.Parameters[<span style="color:#A31515; "@firstname"].Value;
[/code]
As can be seen, it only grabs one field.
If anyone out there has a template on how to retrieve more than one field for more than one record, I can - probably - just go from there.
Many thanks in advance for any assistance!
View the full article