|
You should be asking this question in the ASP.NET forum.
To get a confirmation dialog, you'd probably be writing the code in JavaScript on the client-side.
|
|
|
|
|
Hi,
I have a mostly C++ background and have a small VB.NET problem and was hoping for some advice from you guru's out there in VB land. I am using VS.NET 2002, incase anyone know of a problem with that version.
I am trying to access functions in a unmanaged DLL from a managed VB application. I can get this to work fine until I use a DLL function that has a string as a parameter. When I call a function with a string as a parameter, although the DLL receives the string correcly, the return value of all future DLL calls is garbage. I have created a small sample application (DLL and VB) to demonstrate the problem. I have posted the code in this post (sorry about that but figured it would be nessecary).
Any help would be awesome?
Thanks in Advance,
Charles
Example follows, in the VB application the first two calls to fnTestNumber are handled fine, but the return value from fnTestString and the last fnTestNumber are random.
VB Application:
Imports System.Runtime.InteropServices<br />
<br />
Module Module1<br />
<br />
<DllImport("TestDLL.DLL", _<br />
CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl)> _<br />
Function fnTestNumber(ByVal iTest As Long) As Long<br />
End Function<br />
<DllImport("TestDLL.DLL", _<br />
CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl)> _<br />
Function fnTestString(<MarshalAs(UnmanagedType.LPStr)> ByVal szTest As String) As Long<br />
End Function<br />
<br />
Sub Main()<br />
Dim retcode As Long<br />
<br />
retcode = fnTestNumber(9876)<br />
retcode = fnTestNumber(7654)<br />
retcode = fnTestString("DATAFILE1.DAT")<br />
retcode = fnTestNumber(1234)<br />
End Sub<br />
<br />
End Module
C++ DLL:
__declspec(dllexport) int fnTestNumber(int iTest)<br />
{<br />
return iTest;<br />
}<br />
<br />
__declspec(dllexport) int fnTestString(const char* szTest)<br />
{<br />
return 42;<br />
}
|
|
|
|
|
Hi,
I am used to use P/Invoke between managed C# and native C, here are some suggestions:
- passing a read-only string from managed to unmanaged works fine, it does not even need
MarshalAs(UnmanagedType.LPStr
- by default managed strings are Unicode and get marshaled as 16-bit char collections;
adding CharSet:=CharSet.Ansi should fix that were appropriate.
- I avoid returning a string, since that would mean the unmanaged world needs to create
an object that can continue to exist in the managed world; instead:
- when needing a string result, I tend to pass a StringBuilder object, with its
initial capacity appropriately set, and also pass that capacity; then the unmanaged
world can treat it as a char buffer of specified length.
- always: your calling conventions must match; since I fail to remember the default, I
always make it explicit on both sides.
- most things you do wrong in P/Invoke result in an exception, quite often corresponding
to an access violation.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
In addition to what Luc said, you're using and returning 32-bit numbers in/from your C++ functions, but your VB.NET declarations are Long s. The Long type in VB.NET is a 64-bit signed integer. I think you're actually looking for the Integer type, which is 32-bit signed.
<DllImport("TestDLL.DLL", _
CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl)> _
Function fnTestNumber(ByVal iTest As Integer) As Integer
End Function
<DllImport("TestDLL.DLL", _
CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl)> _
Function fnTestString(ByVal szTest As String) As Integer
End Function
|
|
|
|
|
Right. I missed that one, although I have made similar mistakes myself.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
modified on Tuesday, January 15, 2008 1:41:17 PM
|
|
|
|
|
Ah...... I knew it would be something really annoyingly simple. Thank you both very much for the help. You have no idea the hours of frustration that saved me.
Thanks again,
Charles
|
|
|
|
|
hi guys,
i'm having one word document(2003) with many pages [eg.. 100 pages],
each page has different headers informations
and footers information, and different body text.
now what i want is,
To read the content of each page and write it to another file [Chk1.doc].
one more thing while writing to a file,
while writing in another file, i don't want header and footer instead i want the every page header information to be written at the top every page and footer information to be written at the end of every page and body of the page in the middle.
i want to do this task in vb.net
Pls help me.
Thnks,
regards,
P.Prakash
|
|
|
|
|
I haven't done any Office Interop work in the last 10 years, so I can't tell you exactly how to do it. But, the Visual Studio Tools for Office[^] may be of some help to you.
You may also want to Google for "vb.net retrieve text from Word document" that may give you some close examples.
|
|
|
|
|
|
Please help!!
I need to send email to multiple users within a SQL database. How can I create an email class to send mail using SMTP and get all the users from the database to send it to??
I have never worked with VB and would appreciate the assistance...
Thank you in advance
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
Google results for "send eail from vb.net[^]". Depending on the version of VB.nET you're using, the code can change. You either looking for the System.Web.Mail namespace (.NET 1.x) or the System.Net.Mail namespace (.NET 2.0 and above).
There's a bunch of ways to get data out of SQL server. Google for "get data from sql server in vb.net[^]" for some of the various methods.
|
|
|
|
|
Salam,
I've added a button in my form, from which i close the selected tabpage of my tabcontrol , but in some applications i've seen that there are some tabcontrols that comes with a built in X closing button on the right hand side, just like the one in the VS.Net, also i've realized that the tabpages are not normal, they have a good crazy design, i don't know if this is a separate control or an advaned tabcontrol .
Would you help me please ??
Thank you very much
try to be good if you can't be the best
|
|
|
|
|
I don't really know what you're question is, but I'll take a guess at what you're getting at.
This functionality isn't in the standard TabControl in the toolbox. This is either a customized control or a control in a commercially available library.
|
|
|
|
|
Hey,
Just thougt I'd post a message if anyone was wondering about this project. I deleted it late December 2007, mainly because it was taking too much of my time - in hindsight it was a silly thing todo (as well as pretty selfish), but the code is back online now.
It's still a half baked project (I was going to wait until I had finished it, but since it's an open source project, getting opinions on the software before it's finished is one of the major aspects of open source development!) and I still need to write heaps of documentation for it.
It's got the SQL databases as well this time, so you can run it on either SQL Server or Access (the MySQL database is in the works).
Sorry about any confusion with deleting the project!
Cheers,
Tyron
|
|
|
|
|
Please is it possible to convert .net 2.0 code/program made with vs2005 to .net 3.0 in vs2008 to use some features of .net 3.0?
Thanks
phatkin
|
|
|
|
|
prubyholl wrote: Please is it possible to convert .net 2.0 code/program made with vs2005 to .net 3.0 in vs2008 to use some features of .net 3.0?
Open the VS2005 solution in VS2008 and the wizard will convert it for you.
If you want to make use of .NET 3.0 language features, you will have to modify the code yourself.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
You can open the solution/project in VS2008 and it'll convert the solution/project files to the 2008 format, but it will NOT convert the code for you.
The code should run without issues in most cases. But, if you want to use the .NET 3.0, and above, features, you'll have to rewrite the code by hand to use them. There is no conversion tool that will look for patterns in your code and rewrite it for you.
|
|
|
|
|
Good Morning All
Firstly i would love to thank Dave for the Contribution he made into my Programming skills. number two, lets get to the problem.
i have Succeeded coding without any wizard involved.Thanks to Dave, now i have a Datagrid and am updating only one Field "Tshwane_Prediction", now in my Datagrid i have a button that will Search the for records based on an input, well that works fine and i will update one record from the records and click on Save, the Save button will Confidently send me a Update message and Walla!!!! its done, but my Problem here is that the Returned records will all assign one values, that i have assign to one Record. that means there is something wrong with my update Query.
my Update looks like this
<br />
Dim strUpdate As String = "UPDATE Property_mass SET Tshwane_Prediction = @Tshwane_Prediction" & _<br />
" WHERE (Tshwane_Prediction = @Original_Tshwane_Prediction OR @Original_Tshwane_Prediction IS NULL AND Tshwane_Prediction IS NULL) " & _<br />
" ;SELECT Primary_ID, Boundary_area, Attrib_Code, Lis_Key, Func_Key," & _<br />
" Actual_Extent, Improved_Value, Site_Value, Purchase_price," & _<br />
" Purchase_date, prop_id, confidence_score, fin_ls_prediction, " & _<br />
" new_lis_key, new_func_key, Tshwane_Prediction, matchflag," & _<br />
" source, flagtype FROM Property_mass WHERE (Primary_ID = @Original_Primary_ID)" & _<br />
" ; Update Property_Mass " & _<br />
" set Locked = Null " & _<br />
" WHERE (SUBSTRING(Lis_Key, 1, 4) = @Lis_key And Locked=1) "<br />
<br />
If you have any Article or Tutorial that Explain this Step please send me a link.
Thanks you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hill i solved it, but part of it
i should have included the Primary_key Field that will be mapped in my vb.net code to the original source like this
<br />
Dim strUpdate As String = "UPDATE Property_mass SET Tshwane_Prediction = @Tshwane_Prediction" & _<br />
" WHERE (Primary_ID =@Original_Primary_ID) And (Tshwane_Prediction = @Original_Tshwane_Prediction OR @Original_Tshwane_Prediction IS NULL AND Tshwane_Prediction IS NULL) " & _<br />
" ;SELECT Primary_ID, Boundary_area, Attrib_Code, Lis_Key, Func_Key," & _<br />
" Actual_Extent, Improved_Value, Site_Value, Purchase_price," & _<br />
" Purchase_date, prop_id, confidence_score, fin_ls_prediction, " & _<br />
" new_lis_key, new_func_key, Tshwane_Prediction, matchflag," & _<br />
" source, flagtype FROM Property_mass WHERE (Primary_ID = @Original_Primary_ID)" & _<br />
" ; Update Property_Mass " & _<br />
" set Locked = Null " & _<br />
" WHERE (SUBSTRING(Lis_Key, 1, 4) = @Lis_key And Locked=1) "<br />
<br />
<br />
<br />
<br />
<br />
but Below as you can see there is a Query that updates the Lock if the transaction is Successfull. its Supposed to update the Field to Null when ever the update has taken place. The Problem is that am trying to update based on Search criteria used in the select, so my mistake was that i recreated the Parameter and expected it to carry the value of the sql parameter in the Select statement of the Selected command. So i need to know how to Carry that Value So that i can update the records based on it
Thanks
Please help
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
modified on Tuesday, January 15, 2008 5:13:20 AM
|
|
|
|
|
Move all this SQL code to a stored procedure in the database and this shouldn't be a problem.
I hate the idea of setting a Locked field in the first place, but that's up to you. It not really a supportable solution and can get you in trouble if your code unexpectedly quits for some reason, since the Locked fields will never clear.
|
|
|
|
|
Thanks Dave
Will do, after all a Stored Procedure will will Execute the All these statements,
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hi all
i am facing a problem called query is too complex.
what exactly i m doing is i have a richtextbox. i copy some text from doc file and paste it into richtextbox. then run a insert query that will insert the whole rtf to the database but this cause the error message query is too complex.
can some one tell me how to save the whole rich text of a richtextbox to a database, the field is memo.
thanks in advance.
help everyone
Falling down is not defeat...defeat is when u refuse to get up...
|
|
|
|
|
What does the query look like that's doing the INSERT??
What does the code look like that sets this up and executes the query??
What is the column type of the table that the RTF is going into??
|
|
|
|
|
Hi,
I am working on project and it's dealing with more than 100 textboxes and all of them has to be on single form. Does anyone know how can I add vertical scrollbar? I added control but it didn't seem to work, may be I didn't do something?! I would really appreciate it...
|
|
|
|
|
Hi,
this is the .NET approach, I don't know if it also works for MFC:
put a full-size Panel on the Form and set its AutoScroll true, then add
all the Controls to that Panel.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|