Solved

How can I transfer data from MS Word to MS SQL tables?

Posted on 2016-11-04
4
29 Views
Last Modified: 2016-11-04
Hi there,
I would like to use MS Word to provide customers with a specific form.
When they have filled in this form, I would like to transfer the contents (fields) to a SQL database (Microsoft SQL).
How can I do this?
Kind Regards,
Stefan
0
Comment
Question by:Stefan van Roosmalen
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:John Tsioumpris
ID: 41873981
Usually its the other way around but is possible if you create a form and when the user fills the data to connect to MySQL and upload the data
So you need to start here in order to create a fillable form...
Then you get the ODBC driver from MySQL in order to establish a connection...
But personally i feel that using Word for this kind of job is somewhat an overkill....
If you have Access its much easier...
0
 

Author Comment

by:Stefan van Roosmalen
ID: 41874017
Hi John, thanks for your feedback.
Actually, making a form is not the problem. The real issue is how to transfer to MS SQL.
Can you help me with that?
0
 
LVL 13

Accepted Solution

by:
John Tsioumpris earned 500 total points
ID: 41874042
I guess you could go like this on a click event
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection

conn.connectionString = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& " DATABASE=test;"_
& "UID=venu;PWD=venu; OPTION=3"
conn.CursorLocation = adUseClient
    conn.Open
    Set rs = New ADODB.Recordset
 rs.Open "select  * FROM YourTable where AA=10;", conn, adOpenStatic, adLockOptimistic
rs.AddNew
rs!fieldA= ValueA
......
rs!fieldX= ValueX
rs.Update

rs.close
conn.close

Open in new window

Check the driver version in order for the connection string to work
0
 

Author Closing Comment

by:Stefan van Roosmalen
ID: 41874081
Thanks! This is the way to go...
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now