|
I have an application that loads a dataset into a drop down menu in a DataGridView. Separately you can add or remove information from the SQL server that the dataset is populated from.
How do I update the dataset once the program is already running? (Assuming I have added information to the SQL table)
I have played around, and it seems that the dataset may be complied when the app starts, I could be wrong.
Any thoughts are appreciated,
Adam
--Its not broken if it never worked.
|
|
|
|
|
There must be some code that initially loads the dataset. You should figure out where that is. Once you have, you can call this code from somewhere else in your application to reload it.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Yeah.... The DataGridView allows you to select the dataset in the "properties" window, and doesn't allow you access to the code behind it.. at least that I can find.
I've tried all the datagridview.load .update and dataset.load .update combinations that I can think of, but none seem to have an effect. The program doesn't lock up, it just doesn't update the dataset.
--Its not broken if it never worked.
|
|
|
|
|
In this <a href="http://www.codeproject.com/dotnet/DynamicCompileAndRun.asp" rel="nofollow">Article</a>, an example program will compile and run C# code at run-time. My question is: Is it possible to create an EXE from the code at run-time?
My objective is to make a scripting engine that converts a script to C# code and compiles it to an exe.
|
|
|
|
|
|
|
You are welcome
|
|
|
|
|
Anyone know a free tool that can automatically generate classes from an MSSQL database?
Programming is like Mathematics… you take ONE step at the time!
|
|
|
|
|
The new Visual Studio 2008 (currently in beta 2, will be released by the end of this month) has capability built-in.
In the meantime there are plenty of commercial and open source ORMs. MyGeneration[^] is a free open source one.
Also, if you're doing web development, SubSonic[^] has an all-in-one package that includes some good database abstraction.
|
|
|
|
|
Hi. I need to basically have an equivalent C# struct to my C struct. I need to make a pointer to it. This is the relevant code:
C code:
#if defined(WIN32)
# define DLL_EXPORT __declspec(dllexport)
#else
# define DLL_EXPORT /**/
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct vector
{
uint elem_count; /* number of items in the vector */
uint size; /* size of the vector */
uint elem_size; /* element size */
int (*cmp)(const void *, const void *);
void *table;
};
typedef struct vector VECTOR;
#define CSTATS VECTOR
//function definition:
DLL_EXPORT CSTATS *screate(); // returns CSTATS pointer
...
#ifdef __cplusplus
}
#endif
C# code:
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
unsafe public delegate int cmp(IntPtr a, IntPtr b);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
unsafe public struct VECTOR
{
public uint elem_count;
public uint size;
public uint elem_size;
[MarshalAs(UnmanagedType.FunctionPtr)]
public cmp cp; //C-func: public int (*cmp)(const void *, const void *);
public IntPtr table;
}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
unsafe public delegate VECTOR screate();
[DllImport("myTest.dll", EntryPoint = "screate", ExactSpelling = true)]
public static extern screate scrt();
Now, here is the problem. The C code I want to emulate in C# is this:
CSTATS *st;
st = screate();
In C#, I tried:
VECTOR* st = screate();
VECTOR* st = scrt();
and so on...
The error I get is:
error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('myDll.VECTOR')
So I am looking for help. What is the equivalent C# code that I need, in order to achieve "CSTATS *st; st = screate();" in C?
Thank you for any help.
|
|
|
|
|
Can you repost your code, except this time with <pre> tags around it? It's too hard to read all unformatted like that.
|
|
|
|
|
Sorry, here it is.
C code:
#if defined(WIN32)
# define DLL_EXPORT __declspec(dllexport)
#else
# define DLL_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct vector
{
uint elem_count;
uint size;
uint elem_size;
int (*cmp)(const void *, const void *);
void *table;
};
typedef struct vector VECTOR;
#define CSTATS VECTOR
DLL_EXPORT CSTATS *screate();
...
#ifdef __cplusplus
}
#endif
C# code:
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
unsafe public delegate int cmp(IntPtr a, IntPtr b);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
unsafe public struct VECTOR
{
public uint elem_count;
public uint size;
public uint elem_size;
[MarshalAs(UnmanagedType.FunctionPtr)]
public cmp cp;
public IntPtr table;
}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
unsafe public delegate VECTOR screate();
[DllImport("myTest.dll", EntryPoint = "screate", ExactSpelling = true)]
public static extern screate scrt();
|
|
|
|
|
Hello everyone, I am working on a Browser Helper Object (BHO) and have created a Class Library with the following code.
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using SHDocVw;<br />
using mshtml;<br />
using System.IO;<br />
using Microsoft.Win32;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace WebWatcher<br />
{<br />
<br />
[ComVisible(true),<br />
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),<br />
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")]<br />
public interface IObjectWithSite<br />
{<br />
[PreserveSig]<br />
int SetSite([MarshalAs(UnmanagedType.IUnknown)]object site);<br />
[PreserveSig]<br />
int GetSite(ref Guid guid, out IntPtr ppvSite);<br />
}<br />
<br />
[<br />
ComVisible(true),<br />
Guid("8a194578-81ea-4850-9911-13ba2d71efbd"),<br />
ClassInterface(ClassInterfaceType.None)<br />
]<br />
<br />
public class BHO : IObjectWithSite<br />
{<br />
WebBrowser webBrowser;<br />
HTMLDocument document;<br />
<br />
public void OnDocumentComplete(object pDisp, ref object URL)<br />
{<br />
document = (HTMLDocument)webBrowser.Document;<br />
<br />
foreach (IHTMLInputElement tempElement in document.getElementsByTagName("INPUT"))<br />
{<br />
System.Windows.Forms.MessageBox.Show(tempElement.name != null ? tempElement.name : "it sucks, no name, try id" + ((IHTMLElement)tempElement).id);<br />
}<br />
}<br />
<br />
public void OnBeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)<br />
{<br />
document = (HTMLDocument)webBrowser.Document;<br />
<br />
foreach (IHTMLInputElement tempElement in document.getElementsByTagName("INPUT"))<br />
{<br />
if (tempElement.type.ToLower() == "password")<br />
{<br />
System.Windows.Forms.MessageBox.Show(tempElement.value);<br />
}<br />
}<br />
}<br />
<br />
#region WebWatcher Internal Functions<br />
<br />
public int SetSite(object site)<br />
{<br />
<br />
if (site != null)<br />
{<br />
webBrowser = (WebBrowser)site;<br />
webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);<br />
webBrowser.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);<br />
}<br />
else<br />
{<br />
webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);<br />
webBrowser.BeforeNavigate2 -= new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);<br />
webBrowser = null;<br />
}<br />
<br />
return 0;<br />
<br />
}<br />
<br />
public int GetSite(ref Guid guid, out IntPtr ppvSite)<br />
{<br />
IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);<br />
int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);<br />
Marshal.Release(punk);<br />
<br />
return hr;<br />
}<br />
<br />
#endregion<br />
}<br />
}<br />
When I try to debug the above code, for some reason the BreakPoint which I have got on the code changes to an empty circult with the following warning.
"The Breakpoint will not currently be hit. No symbols have been loaded for this document."
When I check the output window I get the list of DLL files saying no symbole loaded for them also. In order to keep the posting short this is a few line of the output window.
'iexplore.exe': Loaded 'C:\Program Files\Internet Explorer\iexplore.exe', No symbols loaded.
'iexplore.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'iexplore.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'iexplore.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
I have searched the Internet and saddly, have not been able to find any solution for this problem. Many people suggested many different way to fix it but it seems that they don't really know why this problem appears and how it can truly be fixed. They have rather played with the setting of thier compiler and all of the sudden things got working as you can see in posting on this site http://forums.microsoft.com/msdn/showpost.aspx?postid=348785&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=2[^]
Can someone be kind enough to tell me how I can sort this out and why is it that I am unable to get this simple BHO working.
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Couple things off the top of my head: have you hooked Visual Studio up to Microsoft's symbol store for IE? Have you tried attaching a debugger to IE itself?
|
|
|
|
|
Hello Judah,
Thanx for the reply. In order to debug the BHO code, i did the following. I typically have my IE home page set to about:blank . That way I can start up the browser as fast as possible and go where I need to. So, start up the first IE window. The from VS.NET, I use the Attach to Process item in the Debug menu to attach to iexplore.exe . Set breakpoints in my BHO. To break within the constructor.
I hope I was able to explain how I run the debug.
Thank you very much and have a great weekend.
Khoramdin
|
|
|
|
|
Hi All,
In VC++, I can type '@err" in the Immediate Window which acts as a call to GetLastError(). What is the C# equivalent?
Below are my frustrated attempts so far...
Jeff
@err
The name 'err' does not exist in the current context
Debug.Print err;
The type or namespace name 'Debug' is not valid in this scope
error
The name 'error' does not exist in the current context
error.number
The name 'error' does not exist in the current context
debug.print error.number;
; expected
|
|
|
|
|
Call Marshal.GetLastWin32Error to retrieve the last Win32 error that occurred via an error code.
|
|
|
|
|
Hi Judah,
Judah Himango wrote: Marshal.GetLastWin32Error I'll take it there is nothing easier for the Immediate Windows?
Jeff
|
|
|
|
|
I don't know. I suppose you could always write a little Visual Studio macro to make @err mean Marshal.GetLastErrorCode.
I think there isn't any shortcuts (like your @err example) here because managed code doesn't rely on Win32 error codes; it's rare that we need to call GetLastError.
|
|
|
|
|
I am trying to embed a new vector art into a button that is already painted with another vector art.I want this new vector art to take a particular position inside the already existing art that right now paints the button.
I am creating a control template that paints the button based on property triggers & wants to present the new vector art inside the painted art at a specific location through a Content Presenter.Here is how it goes:
<ControlTemplate x:Key="btnCustom" TargetType="{x:Type Button}">
<!-- VisualTree property of ControlTemplate. -->
<Canvas Name="canvas">
<Path Data="" /> *****Here is where I am stuck.I cant find a way to calculate the path where I want to put the content. *********
<ContentPresenter />
</Canvas>
<!-- Triggers property of ControlTemplate. -->
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsFocused" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="canvas" Property="Border.Background" Value="{StaticResource overFocus}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Any ideas??
Vidvict
|
|
|
|
|
If I do not have safe mode and I create a service to restart system and make it automatic, then it will restart my machine every time.
Is there anyway to get rid of it????
I know it is bizare and destructive but still spend some time on it.
I guess its worth it.
Chaos, panic and disorder - my work here is done.
|
|
|
|
|
Thanks for posting in regular English this time. Because you did this, I'll try to answer your question.
d@nish wrote: I do not have safe mode
I don't know what this means. Are you talking about Windows Safe Mode? Are you saying Windows Safe Mode doesn't work?
d@nish wrote: Is there anyway to get rid of it????
You're asking how to get rid of a service that is restarting your machine? Can you just stop the service in Control Panel->Administrative Tools->Services?
Perhaps if you can clarify your question, we might be able to give you a better answer.
|
|
|
|
|
if I create a code that will make it sort of start up program(like narrator) ie
it will start automatically start with the your machine then????
basically it would restart my machine every time start it
can anyone find a solution??
Chaos, panic and disorder - my work here is done.
|
|
|
|
|
You want your application to start up with Windows. Is that what you're asking? If so, look into building a C# Windows Service[^].
|
|
|
|
|
i want my application to shut down my machine and then restart it.
Constraints:
1. I cannot stop that service
2. I cant start my machine in safe mode.
3. my application will start as soon as my machine starts
and i cant test my code as i dont want to crash my machine may i ll create a virtual pc test but still i want to know a solution for this
Chaos, panic and disorder - my work here is done.
|
|
|
|