Saturday, February 25, 2012

access sql server 2000

I am new to using .net. I am told that I need to setup a config file that
will be accessed by a VB.net dll. This vb.net dll will be setup to run every
5 to 10 minutes by a timer that is coded into the vb.net application.
A user will submit a request to obtain data from a HP mainframe.
This web config file needs to be able to do the following:
1. The user will submit the request to a sql server 2000 database (that
resides on a different that where the vb.net application will be running).
2.. The vb.net code will that submit the request for data to the hp
mainframe by using http and xml.
Thus my questions are:
1. How do you setup a connection and retrieve data from the sql server 2000
database that resides with the company's intranet? This will somehow need to
include a connection object and statements oh how to connect to the SQL
server 2000 database. The user name and password are suppose to be passed to
the sql server as part of the connection string.
2. How would I request to the HP mainframe using soap, http, and xml to wrap
up the request?
Thanks!Regarding the SQL Server part of your question, you can use System.Data
SqlConnection and SqlCommand objects to connect to SQL Server and execute
queries. The results can then be retrieved using a SqlDataAdapter
(disconnected) or SqlDataReader (connected).
The example below shows how you can accomplish the task using a
parameteritized SELECT statement. You can find details and many examples in
the Visual Studio reference.
Try
'Create connection
Dim conn As New SqlConnection( _
"Data Source=MyServer;Integrated Security=SSPI;Initial
Catalog=MyDatabase")
'Create command
Dim cmd As New SqlCommand( _
"SELECT MyData FROM MyTable WHERE MyKey = @.MyKey", conn)
cmd.CommandType = CommandType.Text
'Create input paramater for command
cmd.Parameters.Add("@.MyKey", SqlDbType.Int)
cmd.Parameters("@.MyKey").Direction = ParameterDirection.Input
cmd.Parameters("@.MyKey").Value = 1
cmd.Connection.Open()
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
'process dt DataTable here
conn.Close()
Catch ex As SqlExcelption
'exception handling here
End Try
Hope this helps.
Dan Guzman
SQL Server MVP
"Wendy Elizabeth" <WendyElizabeth@.discussions.microsoft.com> wrote in
message news:1693FA1F-8530-4F22-B4D8-EBA89881C8B5@.microsoft.com...
>I am new to using .net. I am told that I need to setup a config file that
> will be accessed by a VB.net dll. This vb.net dll will be setup to run
> every
> 5 to 10 minutes by a timer that is coded into the vb.net application.
> A user will submit a request to obtain data from a HP mainframe.
> This web config file needs to be able to do the following:
> 1. The user will submit the request to a sql server 2000 database (that
> resides on a different that where the vb.net application will be running).
> 2.. The vb.net code will that submit the request for data to the hp
> mainframe by using http and xml.
> Thus my questions are:
> 1. How do you setup a connection and retrieve data from the sql server
> 2000
> database that resides with the company's intranet? This will somehow need
> to
> include a connection object and statements oh how to connect to the SQL
> server 2000 database. The user name and password are suppose to be passed
> to
> the sql server as part of the connection string.
> 2. How would I request to the HP mainframe using soap, http, and xml to
> wrap
> up the request?
> Thanks!

No comments:

Post a Comment