Results 1 to 9 of 9

Thread: [RESOLVED] use msflexgrid as data entry

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Resolved [RESOLVED] use msflexgrid as data entry

    hi,please help.i want to use msflexgrid as data entry,may i how to save msflexgrid data to SQL database??

    thanks!

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: use msflexgrid as data entry

    Read up on "SQL INSERT INTO"
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Re: use msflexgrid as data entry

    koolsid:
    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:
    Code:
    With MSFlexGrid1
    For i = 1 To MSFlexGrid1.rows - 1
    'strsql = "INSERT INTO Lat " & _
    '" (1,2) VALUES " & _
    '" ('" & .TextMatrix(i, 1) & "','" & .TextMatrix(i, 2) & "')"
    please help.thanks
    Attached Images Attached Images  

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: use msflexgrid as data entry

    Can I see the complete code in that Sub?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Re: use msflexgrid as data entry

    koolsid:
    This is the complete code.
    Code:
    Private Sub Command2_Click()
    Dim i As Long
    Dim strsql As String
    Dim conDataConnection As Connection
    Dim rs As ADODB.Recordset
    
     
      Dim conn As New ADODB.Connection
      Set conn = New ADODB.Connection
          Set conDataConnection = New Connection
          conn.ConnectionString = "driver={SQL Server};Server=GRACEKUO;Uid=sa;pwd=sa;database=LAT"
          conn.Open
    
    With MSFlexGrid1
    For i = 1 To MSFlexGrid1.rows - 1
    strsql = "INSERT INTO Lat " & _
    " (1,2) VALUES " & _
    " ('" & .TextMatrix(i, 1) & "','" & .TextMatrix(i, 2) & "')"
    Debug.Print strsql
    conn.Execute (strsql)
    Next
    conn.Close
    Set conn = Nothing
    End With
    End Sub

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: use msflexgrid as data entry

    Is it a DSN less connection? If yes then try with DSN.

    I just modified the string for better readability...

    strsql = "INSERT INTO Lat (1,2) VALUES ('" & _
    .TextMatrix(i, 1) & "','" & _
    .TextMatrix(i, 2) & "')"
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Re: use msflexgrid as data entry

    koolsid:
    i try your code ,but the problem still the same.what is DSN less connection??i install the sql database software in my laptop.

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: use msflexgrid as data entry

    DSN-less is defining the ODBC driver, database, userid, password, etc. all in the connection string. Where as DSN is having all that same information pre-defined. You define it in Control Panel->Admin Tools->Data Sources (ODBC).

    Let me go through your code once again if I am missing something...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    584

    Re: use msflexgrid as data entry

    koolsid:
    hi,i already try the method as your guide,but the problem still the same.The data from msflexgrid save to sql database name is:Lat and tablename:Lat ,field name to save the data is call Data.

    i have change to the code as below:
    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
    The data want to save to the sql database is column1 ,column2 as the photo uploaded.
    please help.thanks!
    Attached Images Attached Images  
    Last edited by gracehskuo; Jun 1st, 2010 at 03:38 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width