lance-tek
06-09-05, 03:09 PM
I need a little help with my SP in SQL server 2003. I am working with vb.net 2003 for this application.
I have two databases, one (DB1) has information that is requested. The other (DB2) has a table that I want to copy data into.
How can I do the following ...
1) Use a button click event to call the sp and pass it a parameter from the querystring (x)
I am guessing something like the following
PrivateSub btnPublish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPublish.Click
Dim myconnection As SqlConnection = New SqlConnection("Server = myserver; database=Db2; user id=USERID; password ='PASSWORD'")
2) Using a stored procedure, select data from DB1 where @parameter = x
thus far I have only the following and I need more but am not sure how to do it.
CREATE PROCEDURE DBO.COPY_DATA (
@RequestID bigint,
@Ann_PostDate datetime,
@AnnUserID varchar(50),
@Ann_Title varchar(200),
@Ann_Body varchar(2000),
@AnnExpireDate datetime,
@AnnDocLink varchar(200)
)
AS begin
insert into DB2.ANNOUNCEMENTS (
Ann_PostDate,
AnnUserID,Ann_Title,
Ann_Body,
AnnExpireDate,
AnnDocLink,
RequestID
)
Values (
@RequestID,
@Ann_PostDate,
@AnnUserID,
@Ann_Title,
@Ann_Body,
@AnnExpireDate,
@AnnDocLink
)
End
Go
The parameters can all be set to a static value easily but, how do I set it up to be dynamic as it will change with every request.
The button click is the approval, the data in DB1 is requested however it does not get written to DB2 until it is approved.
TIA,
-lance
I have two databases, one (DB1) has information that is requested. The other (DB2) has a table that I want to copy data into.
How can I do the following ...
1) Use a button click event to call the sp and pass it a parameter from the querystring (x)
I am guessing something like the following
PrivateSub btnPublish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPublish.Click
Dim myconnection As SqlConnection = New SqlConnection("Server = myserver; database=Db2; user id=USERID; password ='PASSWORD'")
2) Using a stored procedure, select data from DB1 where @parameter = x
thus far I have only the following and I need more but am not sure how to do it.
CREATE PROCEDURE DBO.COPY_DATA (
@RequestID bigint,
@Ann_PostDate datetime,
@AnnUserID varchar(50),
@Ann_Title varchar(200),
@Ann_Body varchar(2000),
@AnnExpireDate datetime,
@AnnDocLink varchar(200)
)
AS begin
insert into DB2.ANNOUNCEMENTS (
Ann_PostDate,
AnnUserID,Ann_Title,
Ann_Body,
AnnExpireDate,
AnnDocLink,
RequestID
)
Values (
@RequestID,
@Ann_PostDate,
@AnnUserID,
@Ann_Title,
@Ann_Body,
@AnnExpireDate,
@AnnDocLink
)
End
Go
The parameters can all be set to a static value easily but, how do I set it up to be dynamic as it will change with every request.
The button click is the approval, the data in DB1 is requested however it does not get written to DB2 until it is approved.
TIA,
-lance