|
You'd get more responses from the database-forum. I haven't used the Reporting Services yet, but I guess that they can use a function or sproc as a datasource. I usually use a construction that's comparable to this;
DECLARE @TEST AS TABLE
(FieldOne VARCHAR(10))
INSERT INTO @TEST VALUES('Hello')
INSERT INTO @TEST VALUES('World')
DECLARE @ArgumentForFieldOne AS VARCHAR(10)
SET @ArgumentForFieldOne = 'He%'
SELECT *
FROM @TEST
WHERE (
(@ArgumentForFieldOne IS NOT NULL AND FieldOne LIKE(@ArgumentForFieldOne))
OR (@ArgumentForFieldOne IS NULL)
)
You'd set @ArgumentForFieldOne to NULL if you don't want to search that particular field. This has the disadvantage that you can't pass NULL as a parameter to search for though. You can bypass this problem by introducing a separate bit that indicates whether you want to filter the field or not;
DECLARE @TEST AS TABLE
(FieldOne VARCHAR(10))
INSERT INTO @TEST VALUES('Hello')
INSERT INTO @TEST VALUES('World')
DECLARE @DoFilterFieldOne AS BIT
SET @DoFilterFieldOne = 1
DECLARE @ArgumentForFieldOne AS VARCHAR(10)
SET @ArgumentForFieldOne = 'He%'
SELECT *
FROM @TEST
WHERE (
(@DoFilterFieldOne = 1 AND FieldOne LIKE(@ArgumentForFieldOne))
OR (@DoFilterFieldOne = 0)
)
You can wrap these constructions in a table-valued function, but a sproc where you pass @DoFilterFieldOne and @ArgumentForFieldOne is also an option.
SQL lingua venusta
|
|
|
|
|
Hey buddies this is my first time working on the Socket Class(Because I wanted to do a project on VOIP)...... and I got a sample code from MSDN which shows how to use the Socket Class ........ I wanted to connect to another PC in a network(only 2 computers which is Peer to Peer i.e there is no Server) ....... but there is one Problem so far Here is the code ......
using System;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace Sample
{
public class GetSocket
{
private static Socket ConnectSocket(string server, int port)
{
Socket s = null;
IPHostEntry hostEntry = null;
hostEntry = Dns.GetHostEntry(server);
foreach (IPAddress address in hostEntry.AddressList)
{
IPEndPoint ipe = new IPEndPoint(address, port);
Socket tempSocket =
new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
tempSocket.Connect(ipe);
The problem is @ the above last line in z CODE BLOCK i.e<br />
(<code> tempSocket.Connect(ipe);
<br />
A socket operation was attempted to an unreachable network 213.55.66.247:80<br />
<br />
So how could I solve this problem.Help me<br />
</code><br />
<br />
the remaining code is as follows next to the above line<br />
<br />
<pre>if (tempSocket.Connected)
{
s = tempSocket;
break;
}
else
{
continue;
}
}
return s;
}
private static string SocketSendReceive(string server, int port)
{
string request = "GET / HTTP/1.1\r\nHost: " + server +
"\r\nConnection: Close\r\n\r\n";
Byte[] bytesSent = Encoding.ASCII.GetBytes(request);
Byte[] bytesReceived = new Byte[256];
Socket s = ConnectSocket(server, port);
if (s == null)
return ("Connection failed");
s.Send(bytesSent, bytesSent.Length, 0);
int bytes = 0;
string page = "Default HTML page on " + server + ":\r\n";
do
{
bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);
page = page + Encoding.ASCII.GetString(bytesReceived, 0, bytes);
}
while (bytes > 0);
return page;
}
public static void Main(string[] args)
{
string host;
int port = 80;
if (args.Length == 0)
host = Dns.GetHostName();
else
host = args[0];
string result = SocketSendReceive(host, port);
Console.WriteLine(result);
Console.Read();
}
}
}
</pre><br />
<br />
Thank you
|
|
|
|
|
Have you tried to ping 213.55.66.247 ?
Do you know if port 80 is opened ?
|
|
|
|
|
Ya I tried to ping 213.55.66.247 and I got a reply...... but what it helps??
stancrm wrote: Do you know if port 80 is opened ?
What do you mean by port 80 is opened ...... I didnt understand it ... or how do i know if it is opened or not ...
Thank you for the responce
|
|
|
|
|
|
Is that good(works well than Socket class) to use WebRequest class for peer to peer network.
Thank you budy
|
|
|
|
|
I don't know, what do you want to do with it. If you just want to download some HTML site, use HttpWebRequest. If you want to send/receive binary, then use TcpClient or Socket.
|
|
|
|
|
I just wanted it to send and recive data in a peer to peer network(only 2 computers)
How abt now. did u get me?
|
|
|
|
|
|
Thank you for your help.But from the start what I wanted was ... just for peer to peer network(only 2pcs) ....but I think the code works for client/server based as I thought abt it ........ How about that?
|
|
|
|
|
Have you tried it once again ?
Before you sent a reply, I tried to ping it, and it was not available.
Now it is available.
|
|
|
|
|
Ya budy i tried it more than once .... it gives me a reply from the command prompt but it is still an error in VS .......
|
|
|
|
|
If you still having problem with connection, check the firewall, most problems are firewall thing.
|
|
|
|
|
Just for example :
It's working for me. No exception.
TcpClient tcpClient = new TcpClient();
tcpClient.Connect("213.55.66.247", 80);
NetworkStream networkStream = tcpClient.GetStream();
byte[] buffer = Encoding.ASCII.GetBytes("Hello World");
networkStream.Write(buffer, 0, buffer.Length);
networkStream.Close();
tcpClient.Close();
|
|
|
|
|
Are you working on a client/server based? ....... By the way I checked the fire wall ..... still a problem..
|
|
|
|
|
Hey budy .... What you works for u didnt work for me .... I think the problem might be with ma pc....
So can you tell me how to check wheter the port is opened or not?? .... or any other means ..
Thank you
|
|
|
|
|
Yea, that means your PC is blocking your application. Or the target PC is blocking your PC..
That's not .NET problem, that is the problem of your windows / firewall.
Using that code, I have tried to connect to that IP with port 80, it's working for me.
|
|
|
|
|
So how am i goin to check wheter the port is opened or not? Because I turrned off the Firewall .. I think the problem may be on the port........... By the way can I send a connection to the pc I am working on(the same pc where the application runs)?
|
|
|
|
|
If you can connect to it, that means port 80 is opened.
If you cannot connect to it, that means target is not available or your IP has been blocked from target PC.
|
|
|
|
|
Hi All,
I have combobox with name cmbClassId.
I have to set the SelectedValue for this combo with the value form the DataTable Cell value.
I have done it like below.
cmbClassId.SelectedValue = (object)dataSet.Tables[Constants.STUDENT].Rows[0]["StudentClassId"];
but still it is showing me null in SelectedValue property of this combo...
please help me out...
Thanks & Regards
Dipak Thesiya
dipak
|
|
|
|
|
Try with SelectedItem property.It seem's that the property doesn't works fine ^.
Life is a stage and we are all actors!
modified on Wednesday, August 19, 2009 6:47 AM
|
|
|
|
|
i am supposed work with SelectedValue Property....
dipak
|
|
|
|
|
Did you remember to set the ValueMember of the ComboBox?
|
|
|
|
|
|
First change the SUBJECT TITLE then peoples may answer your question.
|
|
|
|