The easy answer... Loop through the records of the FG and extract the entered data to put into an insert statement that you can execute via ADO's connection object...
vb5prgrmr:
hi,currently i'm able to insert data to sql database.but have error message appear.if i insert 1 column data to sql database is work fine.after that i try to write second row data us the code below.when i try to insert data to sql
server have this error message appear .
this is the current code:
With MSFlexGrid1
For i = 1 To MSFlexGrid1.rows - 1
'strsql = "INSERT INTO Lat " & _
'" (1,2) VALUES " & _
'" ('" & .TextMatrix(i, 1) & "','" & .TextMatrix(i, 2) & "')"
Last edited by monchichi2; May 27th, 2010 at 04:23 AM.
vb5prgrmr,
hi,i try the method as you guide,but still have error message appear.
The data from msflexgrid save to sql database name is:Lat and tablename:Lat ,field name to save the data isata.
current code:
With MSFlexGrid1
For i = 1 To MSFlexGrid1.Cols - 1
strsql = "INSERT INTO Lat (Data) VALUES ('" & _
.TextMatrix(i, 1) & "','" & _
.TextMatrix(i, 2) & "')"
Debug.Print strsql
conn.Execute (strsql)
Next
conn.Close
Set conn = Nothing
Okay, in your values arguement you are specifing two fields but in your table(fields) arguement, you are only specifing one field and that field uses a reserved keyword!
Now, if both of those values are to go into one field then...
vb5prgrmr:
hi,thanks is work.but then the data saved to database field is not combined together.
for example: column 1 and column 2 from msflexgrid :
column 1 :1 ,2
column 2:21,22
so the the data saved to database field become 4 line data: 1,2,21,22
It would help if you were to tell us what it is that you are trying to do.
You only have one field but 2 columns and those columns are text. The logical way they would be combined is by concantonation as was done in the code given to you above.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.