Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions, OSR, & D&D Variants
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions, OSR, & D&D Variants
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Upgrade your account to a Community Supporter account and remove most of the site ads.
Community
General Tabletop Discussion
*Geek Talk & Media
Question regarding SQL and ASP.NET
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="IcyCool" data-source="post: 3324349" data-attributes="member: 20308"><p>You just want to connect to a database, pull the data, and put it in a text file? Have you done that before in any other languages?</p><p></p><p>Here's a pretty simple way to connect to an Oracle DB and pull data:</p><p></p><p>In the web.config file, you'll want an entry under your <connectionstrings> tag, mine looks similar to the following:</p><p></p><p>[code]</p><p><add name="SampleConnection" connectionString="Data Source=[i]datasource[/i];Persist Security Info=True;User ID=[i]userid[/i];Password=[i]password[/i];Unicode=True" providerName="System.Data.OracleClient"/></p><p>[/code]</p><p></p><p>Then in your code you'll do something like this:</p><p></p><p>[code]</p><p>string sampleConnString = ConfigurationManager.ConnectionStrings["SampleConnection"].ConnectionString;</p><p>string sampleCommand = "Select * from Table1";</p><p></p><p>OracleDataReader simpleReader;</p><p>OracleCommand queryCommand = new OracleCommand();</p><p>OracleConnection dbConnection = new OracleConnection(sampleConnString);</p><p>[/code]</p><p></p><p>In a try-catch block you'll do this:</p><p></p><p>[code]</p><p>dbConnection.Open();</p><p>queryCommand.Connection = dbConnection;</p><p>queryCommand.CommandText = sampleCommand;</p><p></p><p>simpleReader = queryCommand.ExecuteReader();</p><p>[/code]</p><p></p><p>And now you have a dataReader object containing the results of your SQL statement. From there you instantiate a file object, and write out the contents of the dataReader to the file.</p><p></p><p>There are other ways of doing this, and this was for an Oracle database, so you may have to play around with it.</p><p></p><p><em>Edit - I should also note that the above is in C#. You didn't specify C# or VB.NET, so I pulled an example from what I'm most familiar with. </em></p><p></p><p>You might also want to read the info at the following links:</p><p></p><p><a href="http://msdn.microsoft.com/msdnmag/issues/04/06/DataPoints/" target="_blank">MSDN Magazine</a> article about the differences between using datareaders and datasets.</p><p><a href="http://msdn2.microsoft.com/en-us/library/ms171919(VS.80).aspx" target="_blank">Querying data overview</a></p><p></p><p>Or just search for anything on ADO.NET.</p></blockquote><p></p>
[QUOTE="IcyCool, post: 3324349, member: 20308"] You just want to connect to a database, pull the data, and put it in a text file? Have you done that before in any other languages? Here's a pretty simple way to connect to an Oracle DB and pull data: In the web.config file, you'll want an entry under your <connectionstrings> tag, mine looks similar to the following: [code] <add name="SampleConnection" connectionString="Data Source=[i]datasource[/i];Persist Security Info=True;User ID=[i]userid[/i];Password=[i]password[/i];Unicode=True" providerName="System.Data.OracleClient"/> [/code] Then in your code you'll do something like this: [code] string sampleConnString = ConfigurationManager.ConnectionStrings["SampleConnection"].ConnectionString; string sampleCommand = "Select * from Table1"; OracleDataReader simpleReader; OracleCommand queryCommand = new OracleCommand(); OracleConnection dbConnection = new OracleConnection(sampleConnString); [/code] In a try-catch block you'll do this: [code] dbConnection.Open(); queryCommand.Connection = dbConnection; queryCommand.CommandText = sampleCommand; simpleReader = queryCommand.ExecuteReader(); [/code] And now you have a dataReader object containing the results of your SQL statement. From there you instantiate a file object, and write out the contents of the dataReader to the file. There are other ways of doing this, and this was for an Oracle database, so you may have to play around with it. [i]Edit - I should also note that the above is in C#. You didn't specify C# or VB.NET, so I pulled an example from what I'm most familiar with. [/i] You might also want to read the info at the following links: [url=http://msdn.microsoft.com/msdnmag/issues/04/06/DataPoints/]MSDN Magazine[/url] article about the differences between using datareaders and datasets. [url=http://msdn2.microsoft.com/en-us/library/ms171919(VS.80).aspx]Querying data overview[/url] Or just search for anything on ADO.NET. [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Geek Talk & Media
Question regarding SQL and ASP.NET
Top