Using sqlDataSource for merge

Hello.
This should be simple: I create an sqlDataSource using the drag and drop tool in design mode; then, all I want to do is merge with the values from that data source.
Any ideas?
Thanks!
Alex

Can someone please answer this? The examples in the demos invent the field values as they go along…

Would it trouble anyone to answer this, especially those in charge of providing actual service?
The question was:
Simple SQL Server connection: How do you connect to a table on a server and use its data as the datasource for a merge?
Thanks.

Hi
Thanks for your request. Sorry for delay I had to work on other requests. You can try using the following code to achieve this.

// get results from SqlDataSource
DataView account = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments());
// set name of table
account.Table.TableName = "Account";
// open template
Document doc = new Document(Server.MapPath("in.doc"));
// execute mailmerge
doc.MailMerge.ExecuteWithRegions(account);
// save document
doc.Save(Server.MapPath("out.doc"));

Here is my SqlDataSource

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="server=web1;database=LS;uid=sa;pwd=password;" SelectCommand="SELECT * FROM [Account]"></asp:SqlDataSource>

My template looks like the following.

Name Balance Point Rate Month Rate
«TableStart:Account»«Name» «CurrentBalance» «PointRate» «MonthRate»«TableEnd:Account»

I hope that this will help you. Please let me know if you would like to know something else.
Best regards.

Thanks! I’ll try this right now!

Hey – quick question:
Do you have all of the above in VB?
(Yes, I am annoying, but so are most people.)
Thanks!

Hi
Here is code in VB.

'get results from SqlDataSource
Dim account As Data.DataView = CType(SqlDataSource1.Select(New DataSourceSelectArguments()), Data.DataView)
'set name of table
account.Table.TableName = "Account"
'open template
Dim doc As Document = New Document(Server.MapPath("in.doc"))
'execute mailmerge
doc.MailMerge.ExecuteWithRegions(account)
'save document
doc.Save(Server.MapPath("out.doc"))

Best regards.

Thanks! And go figure, now you can post all your code in C# and have the users convert it themselves.

Pretty nifty, when you think about it.

Everything worked beautifully. Thank you for the quick responses and excuse my last-minute neurotic temperament.

You’re doing a great job there at Aspose.