当前位置: 动力学知识库 > 问答 > 编程问答 >

database - How to export a random entry in a datbase to a word table using C#

问题描述:

I am trying to build a windows form application that compiles quiz questions into a pre constructed word table from a database. I am struggling to find the right code to pull a random line from my database (question to one cell, answer to another cell in my table). The idea is to have it automated from a button click event. Through lots of Googling I have figured out how to call up the word document containing the table but not how to write to it from the database.

网友答案:

I just wanted to try to clarify your situation:

  1. You currently have a database of questions and corresponding answers.
  2. You want to have a click event that on a button that will pull a random question and answer to prompt the user.
  3. Then write to a word document the question and answer in whatever order those questions have been chosen.

Here's how I would go about doing this:

  1. Start getting these in List variables These kinds of situations are easier if you can contain data from a database in variables from the beginning rather than trying to use data straight from the database (that might be a personal thing I enjoy but it might help you as well).

  2. Start playing around with word.interop libraries. If I remember correctly, you have to call up the Word App, then call the word document, then write lines individually. Google will help plenty here.

Hopefully this helped

分享给朋友:
您可能感兴趣的文章:
随机阅读: