Showing posts with label retrieving. Show all posts
Showing posts with label retrieving. Show all posts

Monday, March 19, 2012

Help with a connection to a database

Hi

I have uptil now only used the WYSIWYG for retrieving info from my DB, but now i want to insert some information to the DB in a sub.

My connectionstring is in web.config and is as follows

 
<connectionStrings> <add name="shopConnectionString" connectionString="Data Source=IP.ADRESS.GOES.HERE;Initial Catalog=shop;Persist Security Info=True;User ID=MyId;Password=********" providerName="System.Data.SqlClient" /> </connectionStrings>
How do i connect to this connectionstring from inside a sub?

ConfigurationManager.ConnectionStrings["shopConnectionString"].ConnectionString

|||

Ok

Could you be a bit more specific?

for example

Sub add_click'connect to the DB' Execute SQL, for example: INSERT INTO table1 SELECT * FROM table2'close the connectionEnd Sub

That would be great, if you could help me with that.

|||

Dim scon as SqlConnecrion =new SqlConnection( ConfigurationManager.ConnectionStrings["shopConnectionString"].ConnectionString )

use this sql Connecton

|||

i'm getting an error "identifier expected"

Dim MyConn as SqlConnection =new SqlConnection( ConfigurationManager.ConnectionStrings["'<--errormessage
What could be wrong?|||

http://www.dotnetfun.com/articles/framework/2.0/WhatsNew20ConfigurationManager.aspx

See the tutorial to use the same and see where ur doing wrong

|||

Solved it!

Here's what worked for me.

Dim connAs SqlConnection conn =New SqlConnection(ConfigurationManager.ConnectionStrings("shopConnectionString").ConnectionString)
/jonas

Sunday, February 26, 2012

Help storing and retrieving .rtf blob as longvarbinary

Hello,
can anyone point me in the right direction? I have .rtf files stored in a
table as image or sql_longvarbinary data. I would like to be able to pull
out the data and assemble an .rtf file using VBscript or VBA
I'm not sure where to begin when working with image data types.
Thanks
Buddy G.You can take a look at these:
HOWTO: Read and Write BLOBs Using GetChunk and AppendChunk
http://support.microsoft.com/d_efau...b;en-us;1949_75
HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream Object
http://support.microsoft.com/d_efau...;EN-US;q258_038
"Jeff Boyce" <nonse
-oj
"Buddy G" <Buddy at gcsbend dot com> wrote in message
news:ub5xmnyZFHA.3328@.TK2MSFTNGP09.phx.gbl...
> Hello,
> can anyone point me in the right direction? I have .rtf files stored in a
> table as image or sql_longvarbinary data. I would like to be able to pull
> out the data and assemble an .rtf file using VBscript or VBA
> I'm not sure where to begin when working with image data types.
> Thanks
> Buddy G.
>|||Thanks,
let me take a look at those.
Buddy
"oj" <nospam_ojngo@.home.com> wrote in message
news:%23fRZc00ZFHA.3784@.TK2MSFTNGP12.phx.gbl...
> You can take a look at these:
> HOWTO: Read and Write BLOBs Using GetChunk and AppendChunk
> http://support.microsoft.com/d_efau...b;en-us;1949_75
>
> HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream
Object
> http://support.microsoft.com/d_efau...;EN-US;q258_038
>
> "Jeff Boyce" <nonse
> --
> -oj
>
> "Buddy G" <Buddy at gcsbend dot com> wrote in message
> news:ub5xmnyZFHA.3328@.TK2MSFTNGP09.phx.gbl...
a
pull
>

Friday, February 24, 2012

Help retrieving values from 2 similar stored procs

I created one stored proc, then copied it to create another similar stored proc with just some filtering changes in the second. Now I want to obtain the results from both like this:
ProjFee ProjGross DailyRunRate Var1 InHouse1 InHouse2 GrossGoal Group Name PostedAmount
---------
Row# 1 from current stored proc
Row # 2 from called stored proc
so something like this I should get in the end for example when both results are combined:
ProjFee ProjGross DailyRunRate Var1 InHouse1 InHouse2 GrossGoal Group Name PostedAmount
---------
100000 33455 200 300 345555 4455555 5666666 Arizona 56000
103400 22455 900 700 777555 3333555 5444666 Illinois 660000

The first stored proc (CurrentMonthCollections_AZ) attempts to include the results of the second stored proc at the end (CurrentMonthCollections_IL) by calling it and inserting the fields into a temp table.
I was told by Angel to instead convert the second stored proc into a UDF...but having trouble with this.
What is the best approach to get the desired 2 rows back that I need in that fasion?
Here is the code for the 2 stored procs (very long so I will post as as links):
http://www.webfound.net/CurrentMonthCollections_AZ.txt
http://www.webfound.net/CurrentMonthCollections_IL.txt
Look at the end of CurrentMonthCollections_AZ.txt to see where I'm stuck in trying to select the results (ProjFee ProjGross DailyRunRate Var1 InHouse1 InHouse2 GrossGoal Var1 PostedAmount
) from both stored procs.
I don't think UNION is what I want because it will combine stuff...I just want 2 separated rows

"I don't think UNION is what I want because it will combine stuff...I just want 2 separated rows"

Union is what you want:

select 1
union
select 2

returns


1
2

It seems to me that you could parameterize the procedures and get back the two rows that you want, or at least have one procedure and pass in the state you are interested in...that is a lot of proc to deal with though...

|||what about union all ?|||

The difference between the 2 is that union removes duplicates and union all does not

union all is also faster because of that

select 1
union
select 2
union
select 2


select 1
union all
select 2
union all
select 2

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||

Sorry, I should have been clearer:

UNION ALL doesn't eliminate duplicates, UNION does.

UNION ALL is probably the more correct way to go in this case, but it won't really make a difference with such a small set.

|||in this case, there are no dups so it doesn't matter I guess then.|||so I thought UNION puts it all in one row? I must be wrong...

HELP Retrieving remote XML and returning ROWSET

Within a stored procedure, I need to retrieve XML over HTTP from an external
URL, then load some stuff into a recordset and return as such.
Like this, sort-of:
-- *******************************
create procudure queryremote (@.param)
declare @.xmldoc varchar(2000)
set @.xmldoc = (GET 'HTTP://someplaceservesXML.com/script.ext?param=' +
@.param)
sp_preparedocument (@.xmldoc etc.)
SELECT * FROM OPENXML(thexmlthing, "/xpath")
Return
-- *********************************
Just to be clear, this is exactly the opposite of what everyone is trying to
do; many articles on getting XML OUT of SQL server and putting XML data INTO
SQL server, over HTTP.
This requirement is to provide backward -compatibility to
SQL-recordset-aware-only applications. Making an HTTP XML query service
LOOK like an SQL recordset.
Email and post please, thanks a lot!
Richard Weerts
rweerts@.ndis.us
In SQL Server 2000 you have two options:
Do the get on the mid-tier and pass the XML as an argument to the stored
proc.
Write your own extended stored proc to GET the data.
In SQL Server 2005, you can write the function using CLR instead of writing
an extended stored proc.
HTH
Michael
"411XML Richard Weerts" <rweerts@.ndis.us> wrote in message
news:OLr5YmXfEHA.2848@.TK2MSFTNGP10.phx.gbl...
>
> Within a stored procedure, I need to retrieve XML over HTTP from an
> external
> URL, then load some stuff into a recordset and return as such.
> Like this, sort-of:
> -- *******************************
> create procudure queryremote (@.param)
> declare @.xmldoc varchar(2000)
> set @.xmldoc = (GET 'HTTP://someplaceservesXML.com/script.ext?param=' +
> @.param)
> sp_preparedocument (@.xmldoc etc.)
> SELECT * FROM OPENXML(thexmlthing, "/xpath")
> Return
> -- *********************************
> Just to be clear, this is exactly the opposite of what everyone is trying
> to
> do; many articles on getting XML OUT of SQL server and putting XML data
> INTO
> SQL server, over HTTP.
> This requirement is to provide backward -compatibility to
> SQL-recordset-aware-only applications. Making an HTTP XML query service
> LOOK like an SQL recordset.
> Email and post please, thanks a lot!
> Richard Weerts
> rweerts@.ndis.us
>
>