refer to sql tables

AST
Member Posts: 108
Hello,
Can Navision refer to sql table?
I have two tables in the same sql server 2005 database: tableNav created in Navision Object Designer and tableSql created by Sql server tools.
It is possible to get data form tableNav and set it to tableSql using Navision tools? :-k
Can Navision refer to sql table?
I have two tables in the same sql server 2005 database: tableNav created in Navision Object Designer and tableSql created by Sql server tools.
It is possible to get data form tableNav and set it to tableSql using Navision tools? :-k
0
Answers
-
Sure you can. You can use ADO to do this, or you could also create a linked table in NAV.0
-
I think that ADO is good option for my database, but I don't know how to start. I just need a little help - any example about writting data to external databse. I found example about reading data from external database, but it didn't help me much.0
-
You can use the AdoCon.Execute(SQLStatement) method to execute whatever statement you like.
ExampleAdoCon.Execute('INSERT INTO TABLE...');
0 -
A few more examples:
http://www.mibuso.com/forum/viewtopic.php?t=9995&highlight=0 -
Thanks for replaying.0
-
Next problem ... How can I write value as a variable?
That was my ideaCountry.FIND('-'); REPEAT SQLString := 'declare @param varchar(10)' + 'SET @param = Country.Code' + 'insert into sqlTab (name) values (@param)'; ADOConnection.Execute(SQLString); UNTIL Country.NEXT = 0;
but this (SET @param = Country.Code) doesn't work.
Do you have any suggestion how to do this task (export data from Nav table to sql table via ADO)?0 -
You'll have to work with the ".parameters" statement of ADO.
Here is some code:
http://www.freevbcode.com/ShowCode.asp?ID=36870 -
I think I'm close, but I need little more help...
I created Ado parameter, but now I have problem withinsert into
sql statement. That's my codeADOConnection.ConnectionString('Provider=SQLOLEDB;Data Source=star;' + 'Initial Catalog=adotest;User ID=ast;Password= ;'); ADOConnection.Open; ADOCommand.ActiveConnection := ADOConnection.ConnectionString; ADOParameters:=ADOCommand.Parameters; ADOParameter:=ADOCommand.CreateParameter('@var',4,1,3,100); ADOCommand.CommandText := 'insert into dbo.Country (test) values (@var)'; ADOCommand.Execute;
end error "Must declare the scalar variable "@var".
What should I pass as value in insert into statement?0 -
I think you have to create a stored procedure with a parameter.
and call your SP. Something like:ADOConnection.ConnectionString('Provider=SQLOLEDB;Data Source=star;' + 'Initial Catalog=adotest;User ID=ast;Password= ;'); ADOConnection.Open; ADOCommand.ActiveConnection := ADOConnection.ConnectionString; ADOParameters:=ADOCommand.Parameters; ADOParameter:=ADOCommand.CreateParameter('@var',4,1,3,100); ADOCommand.CommandText := 'sp_mycustomStoredProcedure'; ADOCommand.Execute;
in your stored procedure, you could put your INSERT statement.0 -
ok, that's my SP
Create PROCEDURE dbo.sp_SetValue (@var int) AS INSERT INTO dbo.Country (test) values (@var)
What parameter shoul be in ??? place ?ADOParameter:=ADOCommand.CreateParameter('@var',4,1,3,100); ADOCommand.CommandText := 'sp_SetValue ??? '
sorry if it's stupid question, but my code still doesn't work ](*,)0 -
I solved my problem
This code works:ADOConnection.ConnectionString('Provider=SQLOLEDB;Data Source= test;' + 'Initial Catalog=adotest;User ID= test;Password= test;'); ADOConnection.Open; ADOCommand.ActiveConnection := ADOConnection.ConnectionString; ADOParameters:=ADOCommand.Parameters; ADOCommand.CommandText := 'sp_SetValue'; ADOCommand.CommandType := 4; ADOCommand.CommandTimeout:=0; ADOParameter:=ADOCommand.CreateParameter('@var',4,1,3,100); ADOParameters.Append(ADOParameter); ADOCommand.Execute;
I forgot aboutADOParameters.Append(ADOParameter);
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions