|
string sql = "Select Count(*) From TABLE_NAME";
Run this query and catch return value using ExecuteScalar(). If return value equal 0 so GridView.Datasource = null;
Another way; if using DataSet or DataTable use Row.Count property. If Row.Count equal 0 so GridView.Datasource = null;
|
|
|
|
|
I am sorry, but that does not seem to do what I am after.
Lets say I have three columns, titled COL1, COL2 and COL3. When I do a query and rows of data are return and there is no data in COL3 I wish to hide it.
|
|
|
|
|
DataTable myDt = ....(write necessary code)
DataGridView1.DataSource = SupressEmptyColumns(myDt);
private DataTable SupressEmptyColumns(DataTable dtSource)
{
System.Collections.ArrayList columnsToRemove = new System.Collections.ArrayList();
foreach(DataColumn dc in dtSource.Columns)
{
bool colEmpty = true;
foreach(DataRow dr in dtSource.Rows)
{
if (SqlConvert.ToString(dr[dc.ColumnName]) != string.Empty)
{
colEmpty = false;
}
}
if (colEmpty == true)
{
columnsToRemove.Add(dc.ColumnName);
}
}
foreach(string columnName in columnsToRemove)
{
dtSource.Columns.Remove(columnName);
}
return dtSource;
}
|
|
|
|
|
I have been building a GUI that interfaces with 3 services via remoted interfaces. I'm using GenuineChannels (http://www.genuinechannels.com) broadcast engine as the framework for event based communication between services & the GUI. Since you can only register one remoted object per AppDomain (I hope that statement is correct), I've had to create a seperate AppDomain for each UserControl in the GUI so more than one remoted object can be registered. Each UserControl contains a TreeView that needs to be updated via the broadcast engine, or remoted events. Everything appears to be working just as I had hoped, but here is my problem. I've tried using different types of delegates at different scopes within the code & also tried refactoring my code, but I cannot seem to come up with a way to update the TreeView instance within the UserControl from a remoted object in a seperate AppDomain. Here's most of the code from the classes involved. Unimportant peices have been removed.
namespace Console
{
public partial class ControlDelegate : UserControl
{
public ControlDelegate()
{
InitializeComponent();
// Create appdomainsetup information for the new appdomain.
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = System.Environment.CurrentDirectory;
setup.ApplicationName = ("Delegate-" + AppDomain.CurrentDomain.FriendlyName);
//Create evidence for new appdomain.
Evidence evidence = AppDomain.CurrentDomain.Evidence;
// Create the application domain.
AppDomain domain = AppDomain.CreateDomain(("Delegate-" + AppDomain.CurrentDomain.FriendlyName), evidence, setup);
DelegateMessenger remote = (DelegateMessenger)domain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, Assembly.GetCallingAssembly().GetName().Name + ".DelegateMessenger");
Thread thread = new Thread(new ThreadStart(remote.Construct));
thread.Start();
}
/****************************/
this method must be static to refer to it, which is my problem.
/****************************/
public static void tViewDelegateHeartBeat(Objects.Message message, String nickname)
{
System.Console.WriteLine(message.action);
/****************************/
The line below is all that I need to make project functional.
/****************************/
//tViewDelegate.Nodes.Add(message.action + " " + nickname);
}
}
public class DelegateMessenger : MarshalByRefObject, IDelegateMessenger
{
public static String Nickname = "Delegate-" + Assembly.GetExecutingAssembly().GetName().Name;
public static DelegateMessenger Instance = new DelegateMessenger();
public static IDelegateChat iDelegateChat;
public static IDelegateServer iDelegateServer;
public static Object IDelegateChatLock = new Object();
public void Construct()
{
try
{
// Setup remoting with assembly objects as remote object.
IDictionary props = new Hashtable();
props["name"] = "gtcpd";
props["prefix"] = "gtcpd";
props["priority"] = "100";
props["port"] = "0";
GenuineTcpChannel channel = new GenuineTcpChannel(props, null, null);
ChannelServices.RegisterChannel(channel, false);
WellKnownClientTypeEntry remotetype = new WellKnownClientTypeEntry(typeof(SharedChannels.GenuineTcp.GenuineTcpChannel), "gtcpd://127.0.0.1:48886/DelegateMessenger");
RemotingConfiguration.RegisterWellKnownClientType(remotetype);
// Bind client's receiver.
RemotingServices.Marshal(Instance, "DelegateMessenger");
// Subscribe to the chat event.
lock (IDelegateChatLock)
{
iDelegateServer = (IDelegateServer)Activator.GetObject(typeof(IDelegateChat), "gtcpd://127.0.0.1:48886/DelegateServer");
iDelegateChat = iDelegateServer.JoinDialog(Nickname);
}
}
catch (Exception ex)
{
MessageBox.Show(Environment.NewLine + String.Format("Exception: {0}. Stack trace: {1}.", ex.Message, ex.StackTrace));
}
}
public Object ReceiveMessage(Objects.Message message, String nickname)
{
/*****************************/
this works fine if the receiving function is static, but I
need to refer to an instance method to be able to update
the UserControl TreeView (tViewDelegate).
/*****************************/
AppDomain.CurrentDomain.DoCallBack(delegate { ControlDelegate.tViewDelegateHeartBeat(message, nickname); });
/*****************************/
this works if I register only one remoted object within
the GUI AppDomain, which won't work with my current design
since I need to access several remoted objects from other UserControls.
/*****************************/
// http://blogs.msdn.com/csharpfaq/archive/2004/03/17/91685.aspx
/* if (tViewDelegate.IsHandleCreated)
{
try
{
tViewDelegate.Invoke(new tViewDelegateCallback(this.tViewDelegateHeartBeat), new Object[] { message, nickname });
}
catch (Exception ex)
{
MessageBox.Show(Environment.NewLine + String.Format("Exception: {0}. Stack trace: {1}.", ex.Message, ex.StackTrace));
}
}
*/
return null;
}
public override Object InitializeLifetimeService()
{
return null;
}
}
}
I'm hoping someone sees something silly that I'm doing and can point it out. The project is still in its infancy, so I could refactor everything if need be. Any ideas?
modified on Wednesday, March 11, 2009 3:42 PM
|
|
|
|
|
hi,
i created VSTO 2003 addin for outlook inspector. i want to check the attachment when we open any mail item, i want to know how to check and attachment when we open item from inbox.
here is actually what i want..
when we open any inbox item, inspector region opens, if any attachments is present, upon clicking the addin button which is in inspector region i want that attachment to store in specified location. can any one help me in this. i've created addin in inspector region, i need help form this point. please help me.
Thanks.
Arun.
|
|
|
|
|
Could u explain breafly your question?
|
|
|
|
|
Hi!
I'm learning to work with webservice, and now I have a problem..
I'm using this guide:
http://www.exforsys.com/tutorials/asp.net/creating-and-consuming-xml-web-services-with-csharp.html[^]
When I try to compile my console-application, this message appears:
Error 1 The type or namespace name 'Service1' does not exist in the namespace 'MyClient.MyService' (are you missing an assembly reference?) C:\Documents and Settings\Bryan\Mina dokument\Visual Studio 2008\Webbservice\MyClient\MyClient\Program.cs 15 23 MyClient
Error 2 The type or namespace name 'Service1' does not exist in the namespace 'MyClient.MyService' (are you missing an assembly reference?) C:\Documents and Settings\Bryan\Mina dokument\Visual Studio 2008\Webbservice\MyClient\MyClient\Program.cs 15 56 MyClient
The code for the webservice:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
namespace WebServiceExample
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
The code for my console application:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyClient
{
class Program
{
[STAThread]
static void Main(string[] args)
{
MyService.Service1 service = new MyService.Service1();
string message = service.HelloWorld();
Console.WriteLine(message);
}
}
}
|
|
|
|
|
In the project for your console application, has a reference been added to your web service?
|
|
|
|
|
Have you created a web reference to the service ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hmmm, when I'm adding a reference, I right-click on my projectname in the solutionbox and paste the URL of my service. Is that correct or should I do it on a another way?
|
|
|
|
|
1. Open Visual Studio, create your web service and run it. (Do not stop)
2. Open Visual Studio (new one, not close first), create console application
3. Right click to References folder on the solution explorer.
4. Select "Add Service Reference..."
5. write your web service address (For example: http://localhost/Service.asmx)
6. Discover it.
|
|
|
|
|
While creating the proxy service you have used
MyService.Service1 service = new MyService.Service1();
but the namespace says it is WebServiceExample.
try doing this...
WebServiceExample.Service1 service = new WebServiceExample.Service1()
I think it should solve your problem....
|
|
|
|
|
Hi,
I've been asked to look at creating sale orders on a Microsoft Dynamics Retail Management System (RMS). Unlike CRM, there doesn't seem to be any readily available SDK or API that I can download. Nor does there seem to be a version available through my MSDN subscription or through the Microsoft Action Pack.
Can anyone tell me if it's even possible to do any integration work with Microsoft Dynamics Retail Management System? All I want to do is take an order from a web site and pass its details to MS Dynamics RMS.
You'd think it was easy
I've been onto a few forums including the main Microsoft one, but as soon as anyone asks a similar question, several people jump in and try to sell them their services. I'm a programmer - I just need an API to develop against...
Cheers for looking
|
|
|
|
|
It seems that you already have a hard time understanding that this forum is for C# questions, it does not surprise me that you can't find anything on Dynamics.
Good luck.
|
|
|
|
|
hi,
does anyboy know how to use the windows speech in c#
thanks
Have Fun
Never forget it
|
|
|
|
|
yes[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
What what what what what?
You really are not that bright are you. Have a look at John's profile, a few highlights:
Messages Posted 14,676 - Fixture
Articles Submitted 39 - Legend
Half of the catagories on this site, gold and above, legends, fixtures and MVP's were first attained by him.
You'll alsddo end up looking like the last drumstick at the BBQ if he happens to be in a bad mood...
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
wowowo...you mean to say that I have to do what he want me to do...well if its that I dont care. Even its MVP or MVP+, if he insult me or my place then he will be WVP for me.
look at Chris' profile, he never post messages like that...
Messages Posted 16,908 - Fixture
Articles Submitted 103 - Legend
Better is that do not go any further else thing will happen worse...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
What's wrong? Is your nappy wet and mummy won't change it?
I'll be honest, you answer a lot of questions here with a straight face, saving the wrath of others being cast down upon the myriad of morons asking them.
Supporting this twaddle is another thing altogether. Do you ever wish that someone would actually ask a sensible question about C# gving an example of what they have tried and asking how to advance? Or do think thius forum is for imbeciles who can't even use google? I go with the former, which do you choose?
There did I mention race or nationality? No.
Next up: "When Gin goes bad - myth or complete rubbish?" After these words from your local sponsor.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
williamnw wrote: Is your nappy wet and mummy won't change it?
I'm not a water boy
williamnw wrote: Do you ever wish that someone would actually ask a sensible question about C# gving an example of what they have tried and asking how to advance?
did I start that Doubt thing ? No, absolutely not...I always help people but right now the mood is very discourteous
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I have not gone after you. Okay the nappy jibe was a bit below the belt but you are being a big kid here.
YES, John chose to point out that a lot of the rubbish appearing here is from Indians.
NO, You didn't start the /doubt/ crap and I have I belive achnowledged your help here.
The fact remains that as long as the idiots, where ever they come from, get there stoopids answered they will come back. In fact they'll tell the other noobs about the site, it'll be like the whole Dwarf thing all over again; "Come on over! And bring the Ketchup!"
Then the programmers, real programmers will have to find a new place where they can ask real programming questions and get rela programming answers. If that happens Chris will be sad and the Hamsters will have be to released. Hamsters will not last five minutes in Canada.
Do you want to see hamsters DIE? I didn't think so! The only answer is to attach the rot now! Use word plays, 98% don't even understand and the 2/3 won't see the mistakes!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
williamnw wrote: John chose to point out that a lot of the rubbish appearing here is from Indians.
yes thats the crappest point, they all aint from a same place they are from everywhere...Pointing a single or particular place suppose to be a racism
I know the amount of these questions increased but that doesnt mean to leave this place...its like scaring of them. We can hunt them down. The best thing is that if someone gonna create a new account he must answer some basic questions prior to it.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
The best thing is that if someone gonna create a new account he must answer some basic questions prior to it.
Now that a plan! Sitting a test to get membership is a brill idea. I would be happy to sit to earn my membership. Perhaps it could even be made a monthly (optional) feature to help improve performance of current members
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Xmen wrote: if someone gonna create a new account he must answer some basic questions
Like:
Is your sister cute?<br />
Can you stand me a beer?<br />
Your sister, is she dating at the moment?
Two out of three and they're in.
Seriously, there have been talks about this before and Chris has always come down in favour of allowing the noobs in and hoping, against the available evidence, that they will come up to speed. A sort of 'Knowledge through Osmosis' thing. There is no perfect solution, there is only 'us'.
Every now and then (usually around the time the money runs out for someone) there will be a diatribe over stoopids and we all attack them. The fire burns out and a few charred remains can be seen. Soon life returns and we all forget about it.
In related news, Diagio's report a sudden increase in sales following the recent record lemon harvest.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I agree with both of you, and JSOP as well. However, I believe the programming forums are not the place for this. That's what the SB, Lounge and LAD are for depending on the strength on the exact discussion.
Programming questions and programming answers only on this forum in my opinion.
Ignore the stupid questions (downvote them if you must do something) and they'll disappear into the history pages soon enough. If they get no answers, they'll eventually stop posting. Even retards realise after a while that they're wasting their time.
This sort of discussion just dilutes the quality of the programming forums even further.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|