problem using ADO

AngeloAngelo Member Posts: 180
Hello all,

I have a problem when using ADO connection. my code be like this :



IF ISCLEAR(ADOConn) THEN
CREATE(ADOConn);

ConnStr := STRSUBSTNO('%1',
'Provider=Microsoft.Jet.OLEDB.4.0;' +
'Data Source=C:\xxx\ yyy.mdb;Persist Security Info=False');

ADOConn.Open(ConnStr);
CREATE(ADORec);

// Insert
SQLStr :=
'INSERT INTO [DRAWINGS] (' +
'[ID], ' +
'[GROUP_ACCOUNT], ' +
'[ACCOUNT_NO], ' +
'[CARD_NO], ' +
'[CUSTOMER_NAME]) VALUES (' +
'''' + id + ''',' +
'''' + grpacc + ''',' +
'''' + accno + ''',' +
'''' + crdno + ''',' +
'''' + custname + ''')';

ADOConn.Execute(SQLStr);

ADOConn.Close;
CLEAR(ADORec);
CLEAR(ADOConn);

When I try to Run there is error like this :
"Overflow under type coversion text to text ......"

My Navision table :
ID - text 50
Group account - text 50
Account no - text 50
card no - text 50
customer name - text 30

My Access table :
ID - Number
Group account - text 50
Account no - text 50
card no - text 50
customer name - text 30

Anyone can tell me how to solve the problem?


regards,
Angelo

Comments

  • kinekine Member Posts: 12,562
    How long is SQLStr variable? How is defined? It seems that you have too short variable to keep the command...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • garakgarak Member Posts: 3,263
    Your variable SQLStr should be to short.
    Do you make it right, it works too!
  • Igor_BeeoneIgor_Beeone Member Posts: 80
    Hello,
    due to string limit in Nav, try execute sql query directly in AdoConn.Execute function.
    For better understanding try using Text constant with strsubstno function.
    Make some constant like SQLSTR with text:
    INSERT INTO [DRAWINGS] ([ID],[GROUP_ACCOUNT], [ACCOUNT_NO],[CARD_NO],[CUSTOMER_NAME]) VALUES ('%1','%2','%3','%4','%5')
    And then use this const like
    Adoconn.execute(STRSUBSTNO(SQLSTR,id,grpacc,accno,crdno,custname));
    
    Hope it helps.
    Br,
    Igor Beeone
Sign In or Register to comment.