Here I have created sample that will help you out.
HTML
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="Upload" />
<br />
<br />
<asp:GridView ID="gvQuestions" runat="server" AutoGenerateColumns="true" />
</div>
C#
protected void Upload(object sender, EventArgs e)
{
if (this.FileUpload1.HasFile)
{
Application word = new Application();
Document doc = new Document();
string filePath = Server.MapPath("~/Temp/") + Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(filePath);
object missing = System.Type.Missing;
object fileName = filePath;
doc = word.Documents.Open(ref fileName,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
String read = string.Empty;
List<string> data = new List<string>();
for (int i = 0; i < doc.Paragraphs.Count; i++)
{
string temp = doc.Paragraphs[i + 1].Range.Text.Trim();
if (temp != string.Empty)
data.Add(temp);
}
doc.Close(ref missing, ref missing, ref missing);
File.Delete(Server.MapPath("~/Temp/") + Path.GetFileName(FileUpload1.PostedFile.FileName));
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[] { new System.Data.DataColumn("Question"),
new System.Data.DataColumn("Option1"),
new System.Data.DataColumn("Option2"),
new System.Data.DataColumn("Option3"),
new System.Data.DataColumn("Option4")
});
int totalQuestionCount = 0;
System.Data.DataRow dr = dt.NewRow();
for (int i = 0; i < data.Count; i++)
{
if (!data[i].Contains("$"))
{
dr[0] = data[i].Replace("@", "");
}
else
{
int optionCount = 1;
foreach (string option in data[i].Split('$'))
{
if (!string.IsNullOrEmpty(option))
{
dr[optionCount] = option.Replace(";", "");
optionCount++;
}
}
}
if ((i - 1) % 2 == 0 && i != 0)
{
dt.Rows.Add(dr);
totalQuestionCount++;
dr = dt.NewRow();
}
}
((_Application)word).Quit();
gvQuestions.DataSource = dt;
gvQuestions.DataBind();
}
}
VB
Protected Sub Upload(sender As Object, e As EventArgs)
If Me.FileUpload1.HasFile Then
Dim word As New Application()
Dim doc As New Document()
Dim filePath As String = Server.MapPath("~/Temp/") + Path.GetFileName(FileUpload1.PostedFile.FileName)
FileUpload1.SaveAs(filePath)
Dim missing As Object = System.Type.Missing
Dim fileName As Object = filePath
doc = word.Documents.Open(fileName, missing, missing, missing, missing, missing, _
missing, missing, missing, missing, missing, missing, _
missing, missing, missing, missing)
Dim read As [String] = String.Empty
Dim data As New List(Of String)()
For i As Integer = 0 To doc.Paragraphs.Count - 1
Dim temp As String = doc.Paragraphs(i + 1).Range.Text.Trim()
If temp <> String.Empty Then
data.Add(temp)
End If
Next
doc.Close(missing, missing, missing)
File.Delete(Server.MapPath("~/Temp/") + Path.GetFileName(FileUpload1.PostedFile.FileName))
Dim dt As New System.Data.DataTable()
dt.Columns.AddRange(New System.Data.DataColumn() {New System.Data.DataColumn("Question"), New System.Data.DataColumn("Option1"), New System.Data.DataColumn("Option2"), New System.Data.DataColumn("Option3"), New System.Data.DataColumn("Option4")})
Dim totalQuestionCount As Integer = 0
Dim dr As System.Data.DataRow = dt.NewRow()
For i As Integer = 0 To data.Count - 1
If Not data(i).Contains("$") Then
dr(0) = data(i).Replace("@", "")
Else
Dim optionCount As Integer = 1
For Each [option] As String In data(i).Split("$"C)
If Not String.IsNullOrEmpty([option]) Then
dr(optionCount) = [option].Replace(";", "")
optionCount += 1
End If
Next
End If
If (i - 1) Mod 2 = 0 AndAlso i <> 0 Then
dt.Rows.Add(dr)
totalQuestionCount += 1
dr = dt.NewRow()
End If
Next
DirectCast(word, _Application).Quit()
gvQuestions.DataSource = dt
gvQuestions.DataBind()
End If
End Sub
and you can refer below article to insert Datatable value to database
Sceenshot
1) Word File
2)