 |
 |
Index ‹ DotNet ‹ Visual C#.Net
|
- Previous
- 1
- Visual C#.Net >> send keys to dos programsHello everyone,
I don't suppose anyone has successfully managed to simulate keystrokes
to a DOS application using C#? I've tried using SendKeys (only works
for cmd.exe, not an application like edit.com), I've tried creating a
process and redirecting StandardInput and StandardOutput and last but
not least, I've tried it using the user32.dll. The results are similar
every time. It works for windows applications, it works for cmd.exe
but it does not work for dos programs, for instance edit.com.
Is it even possible to achieve what I'm trying to do?
Thanks for the help in advance,
Amadej.
- 2
- Dotnet >> DTS ErrorI'm working with DTS packages from within C#. Everything works i
development and testing, but when I move the application to
production server (an IIS box without SQL installed on the same box) i
throws:
COM object with CLSID {10020202-EB1C-11CF-AE6E-00AA004A34D5} is eithe
not valid or not registered.
Any ideas what needs to be registered, or is there a way to incorporat
the necessary file with my app so a registration is not required?
Here's the code:
// Execute the DTS on SQL Server to export the data
createAccessDB(strAccessDB, strCreateTableSQL);
string strSQLServerName
ConfigurationSettings.AppSettings["SQLServerName"];
string strSQLConnection
ConfigurationSettings.AppSettings["DBConn"];
string strSQLUserID
ConfigurationSettings.AppSettings["SQLUserID"];
string strSQLPassword
ConfigurationSettings.AppSettings["SQLPassword"];
Microsoft.SqlServer.DTSPkg80.Package2 package = ne
Microsoft.SqlServer.DTSPkg80.Package2Class();
UCOMIConnectionPointContainer CnnctPtCont
(UCOMIConnectionPointContainer) package;
UCOMIConnectionPoint CnnctPt;
PackageEventsSink PES = new PackageEventsSink ();
Guid guid = new Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5"); /
UUID of PackageEvents Interface
CnnctPtCont.FindConnectionPoint(ref guid, out CnnctPt);
int iCookie;
CnnctPt.Advise(PES, out iCookie);
object pVarPersistStgOfHost = null;
package.LoadFromSQLServer(strSQLServerName, strSQLUserID
strSQLPassword
Microsoft.SqlServer.DTSPkg80.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default
null, null, null, strDTSPackageName, ref pVarPersistStgOfHost);
foreach (Microsoft.SqlServer.DTSPkg80.GlobalVariable colGlobalVar
in package.GlobalVariables)
{
if (colGlobalVars.Name=="sServerName" |
colGlobalVars.Name=="sAccessDB" || colGlobalVars.Name=="UserID" |
colGlobalVars.Name=="Password")
{
package.GlobalVariables.Remove(colGlobalVars.Name);
}
}
try
{
package.GlobalVariables.AddGlobalVariable("sServerName"
strSQLServerName);
package.GlobalVariables.AddGlobalVariable("sAccessDB"
strAccessDB);
package.GlobalVariables.AddGlobalVariable("UserID", strSQLUserID);
package.GlobalVariables.AddGlobalVariable("Password"
strSQLPassword);
package.AutoCommitTransaction=true;
package.WriteCompletionStatusToNTEventLog=true;
package.Execute();
package.UnInitialize();
package = null;
}
catch(System.Runtime.InteropServices.COMException ex)
{
...
}
catch(System.Exception ex)
{
...
-
robrichar
-----------------------------------------------------------------------
posted via www.WebFrustration.com
- 3
- Microsoft Project >> Duration Question MarkWhat is the purpose of the question make in the Duration column and ho
do you make it disappear?
I'm new to Project (an old hand at Access) so apologize for what i
probably a very rookie question.
Sorry, I seem to have posted this question twice. At least I admitte
to being a rookie.
Thank
--
cassidy
-----------------------------------------------------------------------
cassidym's Profile: http://forums.techarena.in/member.php?userid=3527
View this thread: http://forums.techarena.in/showthread.php?t=85496
http://forums.techarena.i
- 4
- Visual C#.Net >> MdiClientIs there a way to place controls on the surface of MdiClient and have it
always stay in the background when new child forms are loaded into the MDI?
When I place controls on the surface of an MDI app and load child forms, the
controls place on the surface poke through the child form.
In the MDI paradigm, is it not wise/proper to use the MdiClient as a
controls surface?
--
Thanks, John F
- 5
- ADO >> ERROR: Invalid Object NameHi,
I'm currently trying to retrieve information from a specific table within a
SQL Database using the following code:
Dim oSqlCommand As New SqlClient.SqlCommand
oSqlCommand.CommandType = CommandType.Text
oSqlCommand.Connection = mSqlConnection
oSqlcCommand.CommandText = "SELECT * FROM SOMETABLE"
Dim oSqlReader As SqlClient.SqlDataReader
oSqlReader = oSqlCommand.ExecuteReader
oSqlCommand.Dispose()
Connection to the SQL Database is performed like this :
strConnection = "Driver={SQL Server}" & _
";Server=" & mServerName & _
";Database=" & mDatabaseName & _
";Uid=" & mUserID & _
";Pwd=" & mPassword & ";"
mSqlConnection = New SqlClient.SqlConnection(strConnection)
mSqlConnection.CreateCommand()
While performing the query with the SOMETABLE owner mUserID, there is no
problem accessing the SOMETABLE information.
Therefore, while performing the query with the Database System Administrator
and DB owner mUserID, I'm unable to access the SOMETABLE information getting
the Invalid Object Name 'SOMETABLE' error message.
If I tried to perform the same thing using EXCEL query, the SOMETABLE
information could be accessed by both mUserID which is not the case with my
application.
It seems that only the SOMETABLE owner could access the table. Why the
Database System Administrator and DB owner could not access the SOMETABLE? Am
I doing something wrong while connecting to the Database? Do I have to change
permissions? Why is it working with EXCEL and not with my application?
Thanks
--
Francois Chouinard
- 6
- Dotnet >> Please Help! How to add IP Control to the Win32 projectI am using VC++.NET in Win 2000/XP
I have Win 32 project
I want to add IP Address Control to the Dialog
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, (DLGPROC)VSETIP);//load dialo
int FAR PASCAL VSETIP(HWND hDlg, UINT Message, UINT wParam, LONG lParam)//initialization of the dialo
INITCOMMONCONTROLSEX InitCtrls
InitCtrls.dwSize=sizeof(INITCOMMONCONTROLSEX)
InitCtrls.dwICC=ICC_INTERNET_CLASSES
InitCommonControlsEx(&InitCtrls);
HWND ghWndIP = CreateWindow(WC_IPADDRESS,""
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_GROUP
90,64,130,20
hDlg, NULL, hInst, NULL )
...
I can't add IP Address Control
I got the following error msg
error LNK2019: unresolved external symbol __imp__InitCommonControlsEx@4 referenced in function "int __stdcall VSETIP(struct HWND__ *,unsigned int,unsigned int,long)" (?VSETIP@@YGHPAUHWND__@@IIJ@Z
How to add IP Control to the dialog
thank you
Pola
- 7
- Microsoft Project >> Customizing reports in 2002 vs. 2003We use Project 2002 and have been frustrated by the apparent limitations of
the Reports feature. Customizing reports is very canned and inflexible.
Has this greatly improved in Project 2003?
For example, does it let me insert any columns I want in a report? Can the
date ranges be automated (with current date)? Can the filters in a report
be automated for dynamic values?
Or do I still have to create custom tables and only have access to specific
limited tables in the reports etc?
- 8
- Net Framework >> WM_KeyUp message on ComboBoxesThe WM_KeyUp message doesn't seem to be firing for a combobox when the
DropDownType is set to DropDown. Can anyone shed light as to why, and how to
get around it? I'm trying to fix the NoKeyUpCombo inherited combobox (code
below) to work with true ComboBoxes (where you can type into the box OR
select from the list), but every DataGridComboBoxColumn example out there
seems to only support the DropDownType of DropDownList.
Here's the control for those that haven't seen it (the reason for cancelling
the KeyUp is to prevent double-tabbing - the tab KeyDown and KeyUp events
both cause a cell change for some reason):
Public Class NoKeyUpCombo
Inherits System.Windows.Forms.ComboBox
Private Const WM_KEYUP As Integer = &H101
Private Const WM_MOUSEWHEEL As Integer = &H20A
Protected Overrides Sub WndProc(ByRef theMessage As
System.Windows.Forms.Message)
If theMessage.Msg = WM_KEYUP Then
Return
Else
MyBase.WndProc(theMessage)
End If
End Sub
End Class
- 9
- ADO >> DataSet / DataTable SQL UpdatesHi Everyone,
I need to know if this is right after about an hour of reasearch
concerning set-based operations against an ADO.NET DataSet or
DataTable.
It looks like MS discourages the use of anything (legacy) concerning
the use of a "current record".. ie, MoveFirst(), MovePrevious(), etc.
in favor of set based operations on a DataSet or DataTable.
From what I've read, we can "SELECT" records from one of the above
objects, but there's no mechanism to "UPDATE" or "DELETE" rows other
than iterating through an array returned by the .Select() method. Is
this right? I understand that a DataSet/DataTable represents a fully
disconnected source of data and why set-based commands would be a
logical step forward, but why only include "SELECT"?
Thanks in advance for any advice at all!
BILL
- 10
- Dotnet >> saving localization in an excel workbookHi all,
Does anybody know how to save localization in an excel workbook (C#
1.1)? I'm not sure this is possible, but I'm trying to do this so that
numberColumns keep their format no matter what local is set in the
computer where the file is opened.
Thanks in advance,
Swayze
- 11
- ADO >> Connection pool count too high?I am trying to determine if the # of connection pools our app is using is
'normal'/acceptable, or if there is a problem.
Our web application is all asp.net, using ADO.NET and SQL Server 2000 STD.
The app is run on a Windows 2003 Server Web Edition and IIS 6. The
application is broken up into 2 webs in IIS. One that contains only one
Application Virtual Directory, and the other that is broken up into 7
Application Virtual Directories.
Every Sql Command uses the same connection string. All data access opens and
closes its own connection immediately before and after the command is run.
We normally have about 45 - 60 concurrent users of the app at any given
time. And every page runs several sql commands every time they load.
Below are the performance counters from both the web and sql servers that I
thought were important for this research.
142 connection pools and 429 pooled connections seems very high to me. I
know that it is hard to determine what should be 'normal' without knowing
more about the app, but at a very high level, does this seem normal or would
this indicate there is a problem?
Connection string
-----------------
"User ID=<uname>;Password=<pword>;Initial Catalog=<dbname>;Data Source=<ip>;"
Web Server Perf Counters
------------------------
.NET CLR DATA _global_
SqlClient Current # connection pools: 142
SqlClient Current # pooled and nonpooled connections: 429
SqlClient Current # pooled connections: 429
Web Service
Current Connections: 46
Maximum Connections: 158
Maximum Anonymous Users: 91
Get Request/ sec: <10 - 20 avg>
SQL Server Perf Counters
------------------------
SQLServer:GeneralStatistics
User Connections: 86
- 12
- Visual C#.Net >> can't use an array property of a user control in designer?Hi,
I have a user control and I want an array of items to be available to
the user
In my case these items are a class called Needle.
I added a property called Needles to get\set the array (Needle[]) and
it seems to work except that the designer doesn't handle it correctly
In the property page of the designer I see the property and I can
click on it and I get a property window and I can add new Needles.
These are thrown away, they never make it to the cs file and I don't
know why.
The will remain in the design property page until I close VS or
compile.
I have put the code in the Form_Load() to set the array and it works
but the property page does nothing
The code is below, {1} is where I would expect the designer to have
inserted code (similar to {2}) to create the objects.
Anyone have any idea what is wrong?
Vin
/// <summary>
/// Form Code
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private QuickTest.MultiNeedleSlider multiNeedleSlider1;
private void InitializeComponent()
{
//
// multiNeedleSlider1
//
this.multiNeedleSlider1.Location = new System.Drawing.Point(48,
24);
this.multiNeedleSlider1.Name = "multiNeedleSlider1";
this.multiNeedleSlider1.Size = new System.Drawing.Size(312, 72);
this.multiNeedleSlider1.TabIndex = 3;
// {1} would expect the Needles to be new'd here!
}
private void Form1_Load(object sender, System.EventArgs e)
{
// {2} This works perfectly
QuickTest.MultiNeedleSlider.Needle nn = new
QuickTest.MultiNeedleSlider.Needle();
nn.Color = Color.Red;
multiNeedleSlider1.Needles = new
QuickTest.MultiNeedleSlider.Needle[1] {nn};
}
}
//////////////////////////////////////////////////
/// <summary>
/// User Control Code
/// </summary>
public class MultiNeedleSlider : System.Windows.Forms.UserControl
{
private Needle[] m_aNeedles;
public Needle[] Needles
{
get
{
return m_aNeedles;
}
set
{
m_aNeedles = value;
}
}
// begin class Needle
public class Needle
{
private System.Drawing.Color m_colour;
public Needle()
{
m_colour = Color.Black;
}
public System.Drawing.Color Color
{
get
{
return m_colour;
}
set
{
m_colour = value;
}
}
} // end class Needle
}
- 13
- Net Framework >> Problems with Session.IsNewSession - Please HelpHi.
Recently here in my work we added the following code in the Global.asax
file to handled the session expired and redirect users to the home of
the site explaining them the occurred (some thing like "Your session
has expired, please restart your navigation.").
public void Session_Start(Object sender, EventArgs e) {
if(Session.IsNewSession && Request.Headers["Cookie"] != null &&
Request.Headers["Cookie"].IndexOf("ASP.NET_SessionId") >= 0)
{
Response.Redirect("/index.aspx?timeout=1");
// when the param "timeout" exists in the url the user
receives the message "... Session expired ..."
}
}
In our tests the code above works fine, but now sometimes we open the
browser, type the url address of the site and the message "... session
expired ..." appears. This occurs just in some machines and not all the
times we access the site.
Someone knows what is happening??
Thanks
Rodrigo
- 14
- Winforms >> Auto Expanding TextBox/ControlsHi there,
I've googled this problem, and not found a suitable solution yet. I was
wondering if anyone has made any progress?
Basically, I want to make a textbox automagically adjust it's height to show
all the text it contains. So, if I add text then it grows, and it shrinks if
I remove text. This is similar to the CanGrow property in MS Access
controls.
I'm willing to purchase a control if anyone knows of any, I'd just like to
get this cracked without spending *too* much time "fiddling" about!
Any help much appreciated
Tobin
- 15
- ADO >> Oledb Connection from ASP.Net on Windows 2003 does not workThe following code does not work from an ASP.Net application on Windows
2003 IIS 6 (application isolation mode).
Basically I am trying to connect to a Sharepoint catalog through the
oledb provider for Internet publishing (WebDAV)
It works fine from a windows application on Windows 2003. It works in
ASP.net web application on Windows2000
public void Connect()
{
string connString =
"provider=msdaipp.dso;data source=http://myServer/mycatalog";
OleDbConnection conn = new
OleDbConnection(connString);
try
{
conn.Open();
}
catch
{
throw;
}
finally
{
conn.Close();
}
}
I have also tried the following and none of these works on 2003/IIS6
Changed the website to run in IIS 5 isolation mode
added NT AUTHORITY\NETWORK SERVICE to the administrator group
tried opening the connection in the asp.net in a secondary thread
Impersonated the asp.net web application to run as a user with
administrator privileges
Turned anonymous authentication off and ran the website with integrated
authentication so it takes the logon user credentials
Any help to point me in the right direction would be greatly
appreciated
Thanks
Sriram V
|
| Author |
Message |
ValerieReid

|
Posted: Wed Sep 03 13:42:53 CDT 2003 |
Top |
Visual C#.Net >> Help: Can't use "Not"???
I want to set the enabled property of a text box based on if a checkbox is
checked or not. This works....
txtPort.Enabled = ckDefaultPort.Checked;
But, I want the enabled property to be the opposite of the checked value.
Why doesn't this work?
txtPort.Enabled = Not ckDefaultPort.Checked;
It keeps telling my "; expected".
Thanks.
DotNet156
|
| |
|
| |
 |
Paul

|
Posted: Wed Sep 03 13:42:53 CDT 2003 |
Top |
Visual C#.Net >> Help: Can't use "Not"???
"VB Programmer" <EMail@HideDomain.com> wrote:
> txtPort.Enabled = Not ckDefaultPort.Checked;
> It keeps telling my "; expected".
Well, you can't write VB code in C#.
txtPort.Enabled = !ckDefaultPort.Checked;
P.
--
www.CL4.org
|
| |
|
| |
 |
Mickey

|
Posted: Wed Sep 03 13:41:43 CDT 2003 |
Top |
Visual C#.Net >> Help: Can't use "Not"???
You're not using VB, so you can't use Visual Basic syntax.
try:
txtPort.Enabled = !ckDefaultPort.Checked;
or
txtPort.Enabled = (ckDefaultPort.Checked == false);
--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com
"VB Programmer" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I want to set the enabled property of a text box based on if a checkbox is
> checked or not. This works....
>
> txtPort.Enabled = ckDefaultPort.Checked;
>
> But, I want the enabled property to be the opposite of the checked value.
> Why doesn't this work?
>
> txtPort.Enabled = Not ckDefaultPort.Checked;
>
> It keeps telling my "; expected".
>
> Thanks.
>
>
|
| |
|
| |
 |
VB

|
Posted: Wed Sep 03 13:44:11 CDT 2003 |
Top |
Visual C#.Net >> Help: Can't use "Not"???
Sorry, I know, I have to use "!"
"VB Programmer" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I want to set the enabled property of a text box based on if a checkbox is
> checked or not. This works....
>
> txtPort.Enabled = ckDefaultPort.Checked;
>
> But, I want the enabled property to be the opposite of the checked value.
> Why doesn't this work?
>
> txtPort.Enabled = Not ckDefaultPort.Checked;
>
> It keeps telling my "; expected".
>
> Thanks.
>
>
|
| |
|
| |
 |
Sunny

|
Posted: Wed Sep 03 13:46:05 CDT 2003 |
Top |
Visual C#.Net >> Help: Can't use "Not"???
In C# there is no Not, you have to use "!" operator:
txtPort.Enabled = !ckDefaultPort.Checked;
"VB Programmer" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I want to set the enabled property of a text box based on if a checkbox is
> checked or not. This works....
>
> txtPort.Enabled = ckDefaultPort.Checked;
>
> But, I want the enabled property to be the opposite of the checked value.
> Why doesn't this work?
>
> txtPort.Enabled = Not ckDefaultPort.Checked;
>
> It keeps telling my "; expected".
>
> Thanks.
>
>
|
| |
|
| |
 |
Joshua

|
Posted: Wed Sep 03 13:55:01 CDT 2003 |
Top |
Visual C#.Net >> Help: Can't use "Not"???
txtPort.Enabled = !ckDefaultPort.Checked;
"VB Programmer" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> I want to set the enabled property of a text box based on if a checkbox is
> checked or not. This works....
>
> txtPort.Enabled = ckDefaultPort.Checked;
>
> But, I want the enabled property to be the opposite of the checked value.
> Why doesn't this work?
>
> txtPort.Enabled = Not ckDefaultPort.Checked;
>
> It keeps telling my "; expected".
>
> Thanks.
>
>
|
| |
|
| |
 |
| |
 |
Index ‹ DotNet ‹ Visual C#.Net |
- Next
- 1
- Visual C#.Net >> get file names of filesSay I want to get the file name of C:\temp\something.xml and have that
put into a variable so I can encrypt the file and output it to
c:\temp\filename.enc. I have not found anything that solves this for
me.
I tired this
static void Main(string[] args)
{
string fileName = @("C:\","*.xml");
string path = @"C:\*.xml";
string result;
result = Path.GetFileName(fileName);
but that has to be static. Any help is appreciated.
- 2
- Winforms >> Unknown name of a componentHello Developpers,
I would like to learn the name of a component and where to obtain it to use at my project's forms.
When you open the Task Manager of Windows 2000/XP, etc., you see the CPU Usage History and Memory Usage History on the graphical indicator. This indicator like the osiloscopes's display.
If you know the name of this component, please kindly tell me....
I would like to thank You in advance for your sincere considerations.
Sincerely
- 3
- Microsoft Project >> Predecessors are not updatingHi!
I'm using project to schedule out a production chart for 64 units of the
same vehicle.
I have a task "Final Paint" which I have needed to move from prior to Item
46"Inspection" to after Item 46"Inspection". I can move the task with no
trouble, but when I try to update its predecessor to be Inspection (which is
now Item 45), The start date for Final Paint doesn't change.
I have tried entering other tasks as the predecessor to try and get this
line to change "eg predecessor 16FS" and still the this item will not follow
on.
Is this a known problem with project 2003, or am I doing something wrong?
Usually I can manually enter "line no"FS without any trouble.
Please help, thanks in advance....
Susie
- 4
- ADO >> How do I detect a DBNull in a strongly typed DataSet?Although I am able to set a DateTime column to null, it throws an error when
I attempt to test for null... example
Column set to null as follows:
private void InitializePriorsPostedThruTest()
{
object[] key = {cbAgencyID.Value.ToString()};
TwsDS.twsAgencyRow r = (TwsDS.twsAgencyRow)
twsDS1.twsAgency.Rows.Find(key);
r.SetPriorsPostedThruNull();
}
And test for it here (Will ultimately be checking for dates that have been
set):
private void cbAgencyID_RowSelected(object sender,
Infragistics.Win.UltraWinGrid.RowSelectedEventArgs e)
{
object[] key = {cbAgencyID.Value.ToString()};
TwsDS.twsAgencyRow r = (TwsDS.twsAgencyRow)
twsDS1.twsAgency.Rows.Find(key);
if (r.PriorsPostedThru.Value == DBNull.Value)
MessageBox.Show("Null detected");
}
- 5
- Visual C#.Net >> Getting the COM IDataObject interface from the DataObject classThe .Net DataObject class implements the COM/OLE IDataObject interface , so
how do I get it.
I have tried this, but it does not work :
// Declare the COM/OLE IDataObject interface
[ComImport, Guid("0000010E-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDataObject
{
[PreserveSig]
int OleGetData(FORMATETC pFormatetc, [Out] STGMEDIUM pMedium);
[PreserveSig]
int OleGetDataHere(FORMATETC pFormatetc, [In, Out] STGMEDIUM pMedium);
[PreserveSig]
int OleQueryGetData(FORMATETC pFormatetc);
[PreserveSig]
int OleGetCanonicalFormatEtc(FORMATETC pformatectIn, [Out] FORMATETC
pformatetcOut);
[PreserveSig]
int OleSetData(FORMATETC pFormatectIn, STGMEDIUM pmedium, int fRelease);
[return: MarshalAs(UnmanagedType.Interface)]
IEnumFORMATETC OleEnumFormatEtc([In, MarshalAs(UnmanagedType.U4)] int
dwDirection);
[PreserveSig]
int OleDAdvise(FORMATETC pFormatetc, [In, MarshalAs(UnmanagedType.U4)] int
advf, [In, MarshalAs(UnmanagedType.Interface)] object pAdvSink, [Out,
MarshalAs(UnmanagedType.LPArray)] int[] pdwConnection);
[PreserveSig]
int OleDUnadvise([In, MarshalAs(UnmanagedType.U4)] int dwConnection);
[PreserveSig]
int OleEnumDAdvise([Out, MarshalAs(UnmanagedType.LPArray)] object[]
ppenumAdvise);
}
-------------------
DataObject data = new DataObject();
IOleDataObject ido = data as IOleDataObject
--------------
When this is run, ido is null. I have also tried varrious other methods like
using Marshal.GetIUnknownForObject, Marshal.QueryInterface,
Marshal.GetTypedObjectForIUnknown, but none of the approaches work.
What am I doing wrong?
Thanks
Bob
- 6
- Winforms >> Tab key in a datagrid on a modeless dialogHello
I have a datagrid on a modeless dialog and when the focus is on the datagrid
the tab key doesnt work. Now, I understand that when you have a modeless
dialog then there is some kind of message loop missing and that is why the
tab key doesnt get captured. That is why I though I could inherit my own
datagrid and override the ProcessKeyPreview to capture the Tab key. This
only works with the Enter key though. The Tab key never gets sent to the
DataGrid. Does anyone know where the tab goes? Do I have to use the textbox
column in some way to get hold of this one. I also wonder why the Enter key
is seen by the datagrid but not the Tab key.
Thanks for any input
/Peter
- 7
- Visual C#.Net >> Obtain parameter values from methodHow would one obtain the parameter VALUES of a method that has already run?
I can find the method using the StackTrace and StackFrame classes but once I
find the method I would like to obtain the value of one of the parameters
that were passed to the method. Is this possible? Even if I have to use
PInvoke to do so?
I can currently find the parameter TYPEs using reflection but I can not
figure out to obtain the values.
Thanks,
Matt
- 8
- Visual C#.Net >> trouble witch using struct from C dllHello, I'm a "expert of beginner" in C#.
I have a dll - in C. And in this dll is this struct:
typedef
struct msg_s { /* please make duplicates of strings before next call
to emi_read() ! */
int op_type; /* of "op_t" type: operation type; submit (>0), response
(<0) */
union {
struct {
const char* from;
const char* to;
const char* notif_addr;
int notif_type; /* not_t */
const char* validity; /* DDMMYYHHmm */
const char* timestamp; /* DDMMYYHHmmss */
dst_t deliv_status;
int deliv_reasoncode;
const char* deliv_timestamp; /* DDMMYYHHmmss */
const char* text;
int priority;
int bit8; /* data coding scheme */
int numbits; /* number of bits in TD (text) if bit8=1 */
int msg_class;
int rpid; /* rpid == -1 => use RPID value "0000" */
/* rpid == 0 => do not use RPID value */
const char* xservices; /* extra services */
} submit;
struct {
int ack;
int errcode;
const char* sysmsg;
} response;
} uu;
} msg_t;
How can I use this struct in C#?
How can I make in C# the same code as is in C:
msg_t* msg = 0;
msg = emi_msg( emi); //emi_msg is a function whitch return a pointer
optyp = msg->op_type;
Thanks a lot
Pavel Spaleny
- 9
- ADO >> Macro to Generate OleDbCommand for a Stored Procedure callAfter searching for just such a macro/tool, I decided to write one
myself. After writing one myself, I decided to post it for others who
might be searching as I was:
Here's the macro. Since clipboard access is not available in Visual
Studio Macros, it's based off the current selection. What I do is
select my stored procedure code in Visual Studio and run this macro.
The output is put into the Output window pane, and I copy and paste it
from there. It's already saved me hours and I only wrote it
yesterday.
Sky's the limit on customizing this thing. Just please let the world
know if you make some sort of massive improvement. It's just a Macro,
so make all the changes you want to suite your coding style, etc.
By default, if uses a connection object named "conn" and it calls
"ExecuteNonQuery". Also, as you can see, it converts the T-SQL types
that I had immediate need for to OleDbDataTypes. Add as needed. Go
to town!
(I hope word-wrappnig doesn't mess this all up...)
'-----------------------------------------------------------
' Select the entire stored procedure code and run this
Sub CraeteOleDbCommandFromSp()
Dim Win As OutputWindowPane = GetActivePane()
Dim StoredProcedure As String = DTE.ActiveDocument.Selection.Text
Dim RegExProcedure As Regex = New
Regex("procedure\s+(?<Name>[A-Za-z0-9_]+)\s+(?<Parameters>[/@A-Za-z\s/(/)0-9,]+?)[^A-Za-z0-9_]as[^A-Za-z0-9_]")
Dim M As Match = RegExProcedure.Match(StoredProcedure)
Dim spName As String = M.Groups("Name").Value
Dim spParameters As String = M.Groups("Parameters").Value
Win.Clear()
Dim RegExParameters As Regex = New
Regex("@(?<Name>[A-Za-z_0-9]+)\s+(?<Type>[A-Za-z0-9]+)\s*\(?(?<Length>[0-9]*)\)?\s*(?<Output>output|OUTPUT)?")
Dim MC As MatchCollection = RegExParameters.Matches(spParameters)
Win.OutputString("#region " & spName & " call generated by
CreateOleDbCommandFromSp macro" & vbCrLf)
Win.OutputString("OleDbCommand sp = new OleDbCommand();" & vbCrLf)
Win.OutputString("sp.Connection = conn;" & vbCrLf)
Win.OutputString("sp.CommandText = ""{? = CALL " & spName & "(")
Dim ParameterCount As Integer = MC.Count()
For Each M In MC
ParameterCount = ParameterCount - 1
If ParameterCount = 0 Then
Win.OutputString("?")
Else
Win.OutputString("?,")
End If
Next
Win.OutputString(")}"";" & vbCrLf)
Win.OutputString("sp.Parameters.Add(""@RetVal"",OleDbType.Integer);"
& vbCrLf)
Win.OutputString("sp.Parameters[""@RetVal""].Direction =
ParameterDirection.Output;" & vbCrLf)
For Each M In MC
Dim OleDbDataType As String = M.Groups("Type").Value
Select Case OleDbDataType.ToUpper()
Case "BIGINT"
OleDbDataType = "BigInt"
Case "INT"
OleDbDataType = "Integer"
Case "VARCHAR"
OleDbDataType = "VarChar"
Case "SMALLINT"
OleDbDataType = "Smallint"
Case "TINYINT"
OleDbDataType = "TinyInt"
Case "UNIQUEIDENTIFIER"
OleDbDataType = "Guid"
Case Else
OleDbDataType = M.Groups("Type").Value
End Select
Win.OutputString("sp.Parameters.Add(""@" &
M.Groups("Name").Value & """,OleDbType." & OleDbDataType)
If Not M.Groups("Length").Value = "" Then
Win.OutputString("," & M.Groups("Length").Value)
End If
Win.OutputString(");" & vbCrLf)
Next
For Each M In MC
If Not M.Groups("Output").Value = "" Then
Win.OutputString("sp.Parameters[""@" &
M.Groups("Name").Value & """].Direction = ParameterDirection.Output;"
& vbCrLf)
Else
Win.OutputString("sp.Parameters[""@" &
M.Groups("Name").Value & """].Value = " & M.Groups("Name").Value & ";"
& vbCrLf)
End If
Next
Win.OutputString("sp.Connection.Open();" & vbCrLf & "try" & vbCrLf
& "{" & vbCrLf)
Win.OutputString(vbTab & "sp.ExecuteNonQuery();" & vbCrLf)
Win.OutputString(vbTab & "if(
Convert.ToInt32(sp.Parameters[""@RetVal""].Value) != 0 )" & vbCrLf)
Win.OutputString(vbTab & vbTab & "throw new
ApplicationException(String.Format(""Execute of " & spName & " failed
with {0}"",Convert.ToInt32(sp.Parameters[""@RetVal""].Value)));" &
vbCrLf)
Win.OutputString("}" & vbCrLf & "finally" & vbCrLf & "{" & vbCrLf
& vbTab & "sp.Connection.Close();" & vbCrLf & "}" & vbCrLf)
Win.OutputString("#endregion" & vbCrLf)
End Sub
Function GetOutputWindow() As OutputWindow
Return DTE.Windows.Item(Constants.vsWindowKindOutput).Object()
End Function
Function GetActivePane() As OutputWindowPane
Return GetOutputWindow.ActivePane
End Function
- 10
- Visual C#.Net >> Create a string of n pixel width...Since I have no control over a treeview's scroll bars (i'm drawing icons
and text to the right of the treenodes) I've decided to just add some
special text to the end of my tree node text which I will then strip out
when it comes to drawing the treenode into the treeview...
Anyway I know there is a way to get the pixel length of a string that
already exists, but is there a good way to create a string of characters
that are a certain length? Should I just have a function that loops
adding 'x' until it's a certain length? Since this will only be run
when a node is created or when a node's special properties change I'm
just planning on doing this - unless any of you know of a better solution.
Thanks,
Benny
- 11
- Visual C#.Net >> webclient timeouti am a newbie, i want to write a code to download data from web using
webclient
string HTMLstring = "";
WebClient client = new WebClient();
Byte[] HP = client.DownloadData("http://www.microsoft.com");
HTMLstring = Encoding.ASCII.GetString(HP);
is it possible to add a timeout timer for this code, e.g. 10s
or i must use another class, like webrequest to doing so?
Thanks for your help!!
- 12
- ADO >> Which control to use?Hi
I need a layout like this http://www.infovis.biz/listview.jpg which is an MS
Access list box. Which control in vs2008 allows me to do this? The list is
being filled from an underlying table.
I would appreciate a code example if possible.
Many Thanks
Regards
- 13
- Visual C#.Net >> OOD QuestionThis is a design / inheritance qus.
I have class Task.
This is a base class for some specific tasks
Say
WorkOrderTask : Task
TimeSheetTask : Task
Now Task has a function GetDetails() which gets all info about task. This
makes a database call.
I override this in the derived class. For implementing this in derived
class i see following 2 approaches.
Approach 1. WorkOrderTask .GetDetails()
{
Calls base.GetDetails(); to get base details, populates in the
object
Gets details specific to WorkOrderTask, populates in the object
returns;
}
Approach 2. WorkOrderTask .GetDetails()
{
Get details specific to WorkOrderTask as well as the base class
details, populates in the object
returns;
}
The problem with
Approach 1
I have to make 2 database calls.
Approach 2
If theres some change in base class I need to take care of these in all the
derived classes as well.
Whereas, Approach 1 is advantageous here as by modifying only the
Task.GetDetails funciton ( this is the base class ) function i have all the
values and i do not need to touch the derived classes.
Was thinking this might be a very common problem, so perhaps many of might
be able to guide me on the approach i must take here. Perhaps anything other
then the two i have talked about.
Thanks in advance
Sourabh
- 14
- Winforms >> A Newbie QuestionHi All,
I'm trying to develop a prototype for a small Room Booking application. This
is a 3 tier application. The presentation layer consists of Windows Forms.
There will be multiple concurrent clients. The application needs transaction
supportivity.I thought of developing in .NET C#. The data base is going to
be SQL Server 2000.
I thought of following the design guidelines mentioned in the
MSDN,Application Architecture for .NET Designing Applications and Services
from Microsoft
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html
/distapp.asp).
I have some questions. For my distributed application which technology would
be best suitable?. Enterprise Services COM+ components or .NET remoting or
Web Services? How can I take the decision? My application needs quick
response (Speed is important).
Thanks in advance.
Regards,
Risath
- 15
- Dotnet >> LNK2001 with mixed managed/native dll'sHello,
I'm running into a linking problem when trying to build a dll like so...
step1:
native C++ library & managed c++ = managed c++ dll (this one builds fine)
step 2:
managed c++ dll (the one that built ok) & managed c++ = managed c++ dll
step 2 results in this link error...
error LNK2001: unresolved external symbol "public: bool __thiscall
rw::audio::core::System::IsLocked(void)const "
(?IsLocked@System@core@audio@rw@@$$FQBE_NXZ) SpliceUnity.obj
...among others. The one thing I noticed that is similar between all of
these link errors is that the routines they are refering to are const
methods.. for example...
bool IsLocked() const;
Any methods that are not const link fine. By the way, these routines are in
the native c++ library.
Another strange bit of info, if I use the routine IsLocked in both managed
c++ libraries, the one in step 1 still builds fine, and the link errors show
up when linking step 2. If I comment out all of the references to IsLocked
in the step 2 dll, I still get the link error until I comment out the call to
IsLocked in the step 1 dll. Once they are removed from BOTH managed
libraries, the link error disappears.
I've scowered the web but can't find a resolution to this. I'm wondering if
the const at the end of these methods, or the calls to those routines from
within my managed dll's are causing the two to be mangled differently (maybe
using __clrcall instead of __thiscall).
Any help is greatly appreciated.
Thanks
|
|
|