I'm using MS Visual Web Developer Express 2005 and SQL Server 2005 Express. I have a database backend and a few web pages for the front.
I am building a contacts database which is supposed to be able to create excel spreadsheets for mail merge data sources and also to be able to create Outlook contacts from the data stored in the database.
I have a gridview that shows the results of a database query with code like this...
Public Function generatedata(ByVal conn As String, ByVal query As String) As DataTable
Dim connection As New SqlConnection(conn)
Dim command As New SqlCommand
command.Connection = connection
command.CommandType = CommandType.Text
command.CommandText = query
Dim adapter As New SqlDataAdapter(command)
Dim buffer As New DataTable
conn_string = "Data Source=.\SQLEXPRESS;AttachDbFilename=" ....
query = "SELECT * FROM Contact WHERE....
results = generatedata(conn_string, query)
GridView1.DataSource = results
I have check boxes on each row and I have code that takes the primary key (ContactID) for that table and puts them in an array.
So to cut a long story short I want to click a button, pass those ContactIDs to a sql query (or stored procedure), create a new excel spreadsheet, fill it with the query result and save it to the user's desktop.
Also a button to create an Outlook contact and fill the fields with the relevant data is what I need but I don't know how to write code to interact with the two applications. Any ideas will be greatly appreciated.