Data retrieving from table

PoweRoy
Member Posts: 43
i am trying to get some data out of records from a database
database is 3.6 and driver is 3.7
programmed this code in visual C# .net
what i accieved:
-connecting/disc to database
-open/close company
-listing of tables
-open/close tables
-listing of fields of a table
I am trying to get the data out of a record with GetFieldData()
htable and record are both handle's (int)
what i tried:
this one works partially, j is the size of the field and i retrieve that, only the var in the field i dont receive
also used
also tried with both the examples to use the 1 param as a ref (ref string dst )
is i use the function DBL_GetFieldData(int hTable, int record, int fieldnr);
i get a NullReferenceException
with
DBL_GetFieldData(int hTable, int record, int fieldnr); i tried to receive a object cause in VB u receive a variant. no succes
Could anyone look at the code an give me a sollution for this prob that's bothering for couple of days :P
database is 3.6 and driver is 3.7
programmed this code in visual C# .net
what i accieved:
-connecting/disc to database
-open/close company
-listing of tables
-open/close tables
-listing of fields of a table
I am trying to get the data out of a record with GetFieldData()
htable and record are both handle's (int)
what i tried:
this one works partially, j is the size of the field and i retrieve that, only the var in the field i dont receive
//dll loader [DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern int DBL_GetFieldData(string dst, int dstsize, int hTable, int record, int fieldnr); //the parser case "lr" : //list records int record = DBL_AllocRec(htable); DBL_InitRec(htable, record); string s = "temp string"; if (DBL_FindRec(htable, record ,"-") ) { int j = DBL_GetFieldData(s,100,htable, record,1); Console.WriteLine(Convert.ToString(j) + s); Console.WriteLine("findrec succes"); } else result.Add("No records found"); DBL_FreeRec(record); break;
also used
//the dll loading [DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern int DBL_GetFieldData(char[]dst, int dstsize, int hTable, int record, int fieldnr); //the parser case "lr" : //list records int record = DBL_AllocRec(htable); DBL_InitRec(htable, record); char[] s = new char[100]; if (DBL_FindRec(htable, record ,"-") ) { int j = DBL_GetFieldData(s,100,htable, record,1); Console.WriteLine(Convert.ToString(j)); string temp = ""; for (int k = 0 ; k < 100 ; k++) { temp = temp + s[k]; } Console.WriteLine(temp); Console.WriteLine("findrec succes"); } else result.Add("No records found"); DBL_FreeRec(record); break;
also tried with both the examples to use the 1 param as a ref (ref string dst )
is i use the function DBL_GetFieldData(int hTable, int record, int fieldnr);
i get a NullReferenceException
with
DBL_GetFieldData(int hTable, int record, int fieldnr); i tried to receive a object cause in VB u receive a variant. no succes
Could anyone look at the code an give me a sollution for this prob that's bothering for couple of days :P
0
Comments
-
*bump*
Noone knows a sollution?
meanwhile i tried to start another project and try to connect with odbc only the .open isnt working :P suspect the connection string, but whats the valid one for navision?..0 -
cause the first param is a void* i thought using a IntPtr could be helpfull but still i dont get any data:
[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern int DBL_GetFieldData( IntPtr dst, int dstsize, int hTable, int record, int fieldnr);
case "lr" : //list records int record = DBL_AllocRec(htable); //DBL_InitRec(htable, record); not needed only for changing and inserting a record IntPtr s = new IntPtr(); if (DBL_FindRec(htable, record ,"-") ) { int j = DBL_GetFieldData(s,100,htable, record,1); Console.WriteLine(Convert.ToString(j)+Marshal.PtrToStringAnsi(s)); Console.WriteLine("findrec gelukt"); }; break;
but it gives a "An unhandled exception of type 'System.NullReferenceException' occurred in csharptest.exe
Additional information: Object reference not set to an instance of an object" error
are there any other solutions?0 -
due the conversion probs i found a program that convert a .h file to c# code. The program is called Pinvoke Wizard made by Paul Yao, but the problem is that it cant convert the typedefs
is there another way to make the .h file usefull in c#?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