The MASM Forum

General => The Campus => Topic started by: fjb59 on March 28, 2018, 07:10:27 AM

Title: interfacing with the .net framework and oledb
Post by: fjb59 on March 28, 2018, 07:10:27 AM
Are there any good examples on using the .net framwork from masm and using oledb?
Thank you
Title: Re: interfacing with the .net framework and oledb
Post by: aw27 on March 28, 2018, 09:27:18 AM
You need to make a bridge CLR .obj file to have access to the .Net and other Funtastic Microsoft Worlds.
In other words, you need to make the opposite that has been done here:
https://www.codeproject.com/Articles/266717/Mixing-Net-and-Assembly-Language-in-a-standalone
Title: Re: interfacing with the .net framework and oledb
Post by: fjb59 on March 29, 2018, 02:54:17 AM
Quote from: aw27 on March 28, 2018, 09:27:18 AM
You need to make a bridge CLR .obj file to have access to the .Net and other Funtastic Microsoft Worlds.
In other words, you need to make the opposite that has been done here:
https://www.codeproject.com/Articles/266717/Mixing-Net-and-Assembly-Language-in-a-standalone
You mean like making a clr class library project then importing it into my masm project?
Title: Re: interfacing with the .net framework and oledb
Post by: aw27 on March 29, 2018, 05:05:27 AM
Quote from: fjb59 on March 29, 2018, 02:54:17 AM
Quote from: aw27 on March 28, 2018, 09:27:18 AM
You need to make a bridge CLR .obj file to have access to the .Net and other Funtastic Microsoft Worlds.
In other words, you need to make the opposite that has been done here:
https://www.codeproject.com/Articles/266717/Mixing-Net-and-Assembly-Language-in-a-standalone
You mean like making a clr class library project then importing it into my masm project?
Not necessarily, the CLR is "IJW" (It Just Works). Make symbols public on the unmanaged part.
I have another example but will not post it because someone downvoted the article of the previous link. Too much of a coincidence, nobody ever did that before.
Title: Re: interfacing with the .net framework and oledb
Post by: fjb59 on March 31, 2018, 12:22:29 AM
how?
Title: Re: interfacing with the .net framework and oledb
Post by: aw27 on March 31, 2018, 01:56:58 AM
Probably, you should start by downloading the code from the link I provided. There was no downloads in the last few days but there was a downvote from some jerk.
I have nothing else to say about this.
Title: Re: interfacing with the .net framework and oledb
Post by: fjb59 on April 01, 2018, 12:49:18 AM
Quote from: aw27 on March 31, 2018, 01:56:58 AM
Probably, you should start by downloading the code from the link I provided. There was no downloads in the last few days but there was a downvote from some jerk.
I have nothing else to say about this.
Yeah i found it. I'll see what i can do with that. thank you.
Title: Re: interfacing with the .net framework and oledb
Post by: mabdelouahab on April 02, 2018, 02:14:19 AM
 :biggrin:
I'm sorry I didn't notice your topic.

.invoke Connection.CreateInstance,"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=.\MyDataBase.mdb;Persist Security Info=true"
.invoke Connection.Open
.get, Connection.State
.if RAX==ConnectionState_Open
.invoke Command.CreateInstance
.set Command.Connection ,Connection

.set Command.CommandText ,"INSERT INTO Table1 (Field1,Field2)  VALUES (2018,'Masm64');";
.invoke Command.ExecuteNonQuery

.set Command.CommandText ,"Select * From Table1;";
.invoke Command.ExecuteReader ,addr vDataReader
MOV DataReader,RAX

@@:
.invoke DataReader.Read
CMP RAX,0
JE  @F
.invoke DataReader.GetInt32,0
invoke printf,"\n ID =%d,",RAX
.invoke DataReader.GetInt32,1
invoke printf," Field1 =%d,",RAX
.invoke DataReader.GetString,2
invoke wprintf,Of_Bstr(" ,Field 2 =%s"),RAX
jmp @B
@@:
invoke MessageBoxA,0,"operation complete",0,0
.else
invoke MessageBoxA,0,"Unable to open connection",0,0
.endif