Using VB.NET to export data from SQL Server 2005 to Excel

Hi There,

I just want to know how to export data from SQL Server 2005 to an excel spread sheet, using VB.NET?

Thanks

SJB

 

0
s_j_b
1/4/2007 8:32:30 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

1 Replies
1020 Views

Similar Articles

[PageSpeed] 41

Everytime I should export data from SQL to Excel with code, I simply create a ; seperated file (*.csv).

So if you want to do the same you can simply use ADO.Net to query your database and get a result set from your tables. Walk trough the rows and get its value and create a textfile with the System.IO namespace.

The file can look like:

column1;column2;column3

value1;value2;value3

value1;value2;value3

The first row can if you want have the name of the column that should be displayed in Excel. Remember to seperate the columns with a comma ( ; ). Each row represents the value from your data source, each value for each column is seperated with a comma.


/Fredrik Normén - fredrikn @ twitter

Microsoft MVP, MCSD, MCAD, MCT

ASPInsiders
My Blog
0
Fredrik
1/4/2007 9:37:37 AM
Reply:

Similar Artilces:

Attach SQL DB to SQL Server 2005 using VB.Net
Is there any way to attach a SQL DB to SQL Server 2005 using VB.Net?  If so can you also set security? Can you rephrase your question? Attach SQL DB from which version of SQL server ? Look up books online for sp_attachdb and sp_detachdb.***********************Dinakar NethiLife is short. Enjoy it.*********************** I have a DB that was created in SQL Server 2005.  I have a website that displays data from systems all over the world.  Each system sends it's data to it's own DB.  The customer can then go to a website and see the data at real time.  What ...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

How to Data Transfer From Excel to Microsoft SQL Server Data base Using .Net.
Hai All, How to Data Transfer From Excel to Microsoft SQL Server Data base Using .Net. I have one Excel Sheet in that sheet 15 Fields (attributes) and 3000 records are there. In this 3000 records i want to store this (Excel) data into  5 related tables on Sql Server Database Using .Net.   How to store Excel Sheet data into Sql Server database. Please help me as soon as possible. Thank You Very Much...Have a Good Day... With RegardsSridhar...

help
This is my first project and I am badly in need of help. I have made a custom form and do not want to use a detailsview to insert data so I made a web form. I am not able to connect and insert. Here is my connection in web.config. <connectionStrings> <add name="PMRConnectionString" connectionString="Data Source=CHSSQL3;Initial Catalog=PMR;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>  The following code is my default.aspx source code. Do I put the connection under the insertbutton? What code would I use for the connection? ...

export table into excel using vb.net 2005
hi all..... i selected some records from database and bind it in table (asp.net table)........ but i wanna add another function which is "export excel function" ....... i wanna export the table (which i bind the records into it) to excel format....  how can i do it ? thanks Hi mate, Here is a simple function i use last time. let me know if you need more help.         Public Shared Sub ExportToExcelFile( _            ByVal gvValue As GridView, _      &...

SQL Server Reporting Services for SQL SERVER 2000 AND Visual Studio.NET 2005 .NET 2.0
Hi, Which version of SQl Server Reporting Services will work with SQL SERVER 2000 in pararrel with ASP.NET 2.0 (.NET 2.0 framework)?  Thanks, Azam HighOnCodingWanna get high! Hi, Okay I got the answer. Yes, we can use the SQL SERVER 2005 Reporting Services with SQL SERVER 2000. HighOnCodingWanna get high! ...

Export data from dataset to excel sheet using vb.net
in buttom click event i wrote the code, all the content from database stored in a dataset but i can't export data from dataset to exel sheet any one please help me my email id is "msd200623@rediffmail.com" i sent my code Protected Sub btndownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btndownload.Click Dim userid As String Dim tempmobileno As String = "" 'Dim reader As SqlDataReader userid = Session("user") Dim total As Integer = 0 Dim selectedrefid As String = &quo...

Writing Data From SQL Server to MS Word using VB.NET
Hi All, I need to write data from SQL Server to MS Word. I have never done that and even I dont have any idea how to proceed. I really apprecite if any body can help me. Please post sample code if any. Thanks in advance, Kumar. Word has a fairly robust object model. For starters you should create windows application project and add a COM reference to the Microsoft Word type library. The following code will create a document and add some text: Dim objWord As New Word.Application() Dim objDoc As Word.Document objWord.Visible = True ...

Converting Web Site from Vb.Net 2003 to Vb.Net 2005
I have a web site in vb.net 2003 that I what to convert to vb.net 2005. I open my web site in the visual studio 2005 by Local IIS option. I follow the steps of the visual studio conversion wizard.In the conversion report I received the following warning 'Referencepath' settings have not been converted.  Can anyone tell what I have to do to make this warning disappear? Best regards,Sérgio 'Referencepath'  is a property you can set with with VS2003 project file, sothat when ever you to do Add reference this path is serached for class libraries.  We do not  have that ...

uploading a image in to the sql server 2005 database using vb.net 3.5
i am currently developing a web project using asp.net.i need to upload a image file to the database using asp.net.i am using linq to interactwith the database. can some one help me in writing these codes. {i need to know how to get the image size and i need the image content type to upload image) please let me know what are the codes i should use to get the image size and content type. i have used the following code but no use                           &n...

VB.NET Codebehind Code to Update SQL Server 2005 Using SQLDataSource Control?
Hi, I am a newbie in using ASP.NET 2.0 and ADO.NET.  I wrote a hangman game and want to record statistics at the end of each game.  I will create and update records in the database for each authenticated user as well as a record for the Anonymous, unauthenticated user.  After a win or loss has occurred, I want to programmatically use the SQLDataSource control to increment the statistics counters for the appropriate record in the database (note I don't want to show anything or get user input for this function). I need a VB.NET codebehind example that will show me how I sho...

Getting only the first paragraph of data from sql server 2005 in vb.net 2.0
Hi all, I have a table in sql server which consists of two colums. column 1 contain "id" integer and column 2 contain "body" varchar(max). For example: id - 1 body - French Industrial production sharply decreased 1.5% month-on-month in November, reversing from a 2.1% increase seen in October, the statistical office Insee said in a report Thursday. Economists were looking for a 0.6% fall. Production in the automotive industry fell steeply 5.3% versus 7.5% rise in October, while energy output declined 2% from 2.1% recorded in the previous month. In the construction...

shopping cart in VB.NET, uses SQL server express edition 2005, anyone?
Hello i want to create a shopping cart which uses SQL server express 2005 as the database for my school project...Any good tutorials for this? Perhaps you can delve in to the source code of some of the open source offerings out there? Maybe DotShoppingCart or dashCommerce, both of which you can find links to on the Starter Kits and Community Projects page.Gavin HarrissPortfolio: www.gavinharriss.com Thank you very much for the suggestion! :)  my friend gave me a great shopping cart code which uses VB.net and SQL server express edition! Once again, thanks :)  ...

moving data from vb.net 1.1 Datagrid to sql server 2005 database
Hi, I was hoping someone could help me with a problem I am having. I can get the datagrid to populate from the database fine, like so:     Public Sub BindTheData()         Dim strConn As String        strConn = System.Configuration.ConfigurationSettings.AppSettings("ConnectionString")        Dim objConn As SqlConnection        objConn = New SqlConnection(strConn)        Dim myCmd As SqlComman...

Web resources about - Using VB.NET to export data from SQL Server 2005 to Excel - asp.net.web-forms

Export - Wikipedia, the free encyclopedia
An export of a good occurs when there is a change of ownership from a resident to a non-resident; this does not necessarily imply that the good ...

Export - Wikipedia, the free encyclopedia
An export of a good occurs when there is a change of ownership from a resident to a non-resident; this does not necessarily imply that the good ...

Facebook To Developers: No Using Platform To Export User Data To Other Social Networks
Facebook issued a stern reminder to developers that its platform cannot be used to export user data to other social networks without permission. ...

Facebook Adds Per Post Impression Data to Page Insights Exports to Help Brands Track Their Performance ...
Some Facebook Page admins are now seeing a new tab called “Per post” in the data exports from Page Insights. Data in the tab includes impressions ...

Thread: Why is Twitter letting us export?
... Instagram and how they own your pictures (not mine, I never used the service) it raises the question as to why Twitter is letting us export ...

Export Import Business Group
Here we are, people in the business of export and import from all over the world. I invite you people also to join for more info of the business ...

VineDrive (Best Vines download, export and save vine downloader for iPhone and iPad) on the App Store ...
Get VineDrive (Best Vines download, export and save vine downloader for iPhone and iPad) on the App Store. See screenshots and ratings, and read ...

Iran to boost oil exports - Business Spectator
OPEC member to export an additional 500,000 barrels per day after sanctions lifted.

South-east Asia and India the mainstays of Australia's future coal exports
South-east Asia and India will be the mainstays of growth for Australia's coal export industry, helping our coal exporters regain the mantle ...

Apple Watch drives decline in Swiss watch exports
Months after the Apple Watch launched around the world, exports of Swiss watches have reached a six year low and stand at just $2 billion, according ...

Resources last updated: 11/22/2015 11:07:02 AM