|
Hello.
I'm using ADO.Net data services and i'm trying to do some kind of API to access to a data base in a remote server, execute a querie there and bring the data to me.
What i have to use, and how?
If you know some place with examples(code) send me the links.
Thank´s. When i finish i will share the code with everyone.
Wonderfull 2010 for everyone.
|
|
|
|
|
You don't need to do anything in your code. Set up your database to allow remote connections. You can do this using Surface Area Configuration in your server.
Then, look for connection string for a remote database in ConnectionStrings.com and you are done.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hi
Thanks for your reply. I will try your advices. When I've done i will tell you.Thanks
(By the i'm portuguese so, excuse my english )
|
|
|
|
|
Hi,
Im working with some programmers on a project. We are creating a software piece and have some problems with form/table design. Im trying to take the technical look out of the form and give it a more designed look. I have included a screen shot.
What I want to do is:
1. Design the header of the table.
2. Create alternate row colours
3. Use Grapical buttons instead of the Edit Delete Buttons.
I have tried looking for skins etc for tables, but no luck. While Im not experienced in VB.net I have a team that is. Im just looking for someone to point me in the right direction. Thanks for any help.
Kind Regards,
Thomas
|
|
|
|
|
Thomas O'Donoghue wrote: While Im not experienced in VB.net I have a team that is
Are you sure they are? They should know how to do these common tasks. Most of these are properties of tables in .net, so are easy to implement.
Bob
Ashfield Consultants Ltd
Proud to be a Code Project MVP
|
|
|
|
|
hi......
i just want to convert an arraylist into bytearray via object in clientside and again convert this bytearray into arraylist in server side.could somebody help me on this.
i tried a lot.
the arraylist contents are from a file whose name is obtained in client.
but i could not get the answer.
i would be thankful to you...
my codings are as follows:
Server:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;
namespace ConsoleApplication1
{
[Serializable]
class Program
{
static void Main(string[] args)
{
IPEndPoint ip = new IPEndPoint(IPAddress.Any, 9999);
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Bind(ip);
s.Listen(10);
Console.WriteLine("Waiting for a client...");
Socket cli = s.Accept();
IPEndPoint cliep = (IPEndPoint)cli.RemoteEndPoint;
Console.WriteLine("Connected with {0} at port {1}", cliep.Address, cliep.Port);
byte[] buffer = new byte[1024];
cli.Receive(buffer);
string fname = Encoding.ASCII.GetString(buffer);
Console.WriteLine("filename is " + fname);
Console.ReadLine();
byte[] buf = new byte[1024];
cli.Receive(buf);
Object obj = new Object();
obj = bytearraytoobject(buf);
ArrayList al = obj as ArrayList;
int i = 0;
foreach (Object o in al)
{
Console.WriteLine("\t[{0}]:\t{1}", i++, o);
}
Console.WriteLine();
Console.ReadLine();
}
static Object bytearraytoobject(byte[] buffer)
{
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
ms.Write(buffer, 0, buffer.Length);
ms.Seek(0, SeekOrigin.Begin);
Object obj = (Object)bf.Deserialize(ms);
return obj;
}
}
}
client:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;
namespace ConsoleApplication2
{
[Serializable]
class Program
{
static void Main(string[] args)
{
IPEndPoint ip = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9999);
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
s.Connect(ip);
}
catch (SocketException e)
{
Console.WriteLine("Unable to connect to server" + e);
return;
}
Console.WriteLine("Enter the input file ");
string inp = Console.ReadLine();
s.Send(Encoding.ASCII.GetBytes(inp));
StreamReader sr = new StreamReader(@"c:\" + inp);
ArrayList al = new ArrayList();
while (!sr.EndOfStream)
{
al.Add(sr.ReadLine());
}
Object o = (Object)al;
byte[] buffer = new byte[1024];
buffer = objecttobytearray(o);
s.Send(buffer);
Console.ReadLine();
}
static byte[] objecttobytearray(Object obj)
{
if (obj == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, obj);
return ms.ToArray();
}
}
}
|
|
|
|
|
you should edit your post and add PRE tags to that code in order to get it formatted so anyone could read it.
|
|
|
|
|
thank you very much for ur kind reply........
i have worked on it and found the solution by myself.
anyway please help me on my later questions regarding my doubts in .net.......
actually it is to generate some random questions by sending the file contenets from client to server and then the server should generate random questions(say 5) from it and the send back to the client.....
THANKS FOR THIS...
ADVANCE THANKS to answer for my later questions.
my code is as follws:
Server:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
IPEndPoint ip = new IPEndPoint(IPAddress.Any, 9999);
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Bind(ip);
s.Listen(10);
Console.WriteLine("Waiting for a client...");
Socket cli = s.Accept();
IPEndPoint cliep = (IPEndPoint)cli.RemoteEndPoint;
Console.WriteLine("Connected with {0} at port {1}", cliep.Address, cliep.Port);
byte[] buffer = new byte[1024];
cli.Receive(buffer);
string fname = Encoding.ASCII.GetString(buffer);
Console.WriteLine("filename is " + fname);
Console.ReadLine();
cli.Receive(buffer);
Object obj = new Object();
obj = bytearraytoobject(buffer);
ArrayList al = (ArrayList)obj;
int i = 0;
foreach (Object o in al)
{
Console.WriteLine("\t[{0}]:\t{1}", i++, o);
}
Console.WriteLine();
ArrayList qal=new ArrayList();
Random rnd = new Random(DateTime.Now.Millisecond);
for (int counter = 0; counter < 5; counter++)
{
int randomindex = rnd.Next(al.Count);
Console.WriteLine("{0}:{1}", counter+ 1, al[randomindex]);
qal.Add(al[randomindex]);
}
foreach (Object o in qal)
{
Console.WriteLine("\t[{0}]:\t{1}", i++, o);
}
Object ob = (Object)qal;
buffer = objecttobytearray(ob);
cli.Send(buffer);
Console.ReadLine();
}
static Object bytearraytoobject(byte[] buffer)
{
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
ms.Write(buffer, 0, buffer.Length);
ms.Seek(0, SeekOrigin.Begin);
Object obj = (Object)bf.Deserialize(ms);
return obj;
}
static byte[] objecttobytearray(Object obj)
{
if (obj == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, obj);
return ms.ToArray();
}
}
}
client:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
IPEndPoint ip = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9999);
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
s.Connect(ip);
}
catch (SocketException e)
{
Console.WriteLine("Unable to connect to server" + e);
return;
}
Console.WriteLine("Enter the input file ");
string inp = Console.ReadLine();
s.Send(Encoding.ASCII.GetBytes(inp));
StreamReader sr = new StreamReader(@"c:\" + inp);
ArrayList al = new ArrayList();
while (!sr.EndOfStream)
{
al.Add(sr.ReadLine());
}
Object o = (Object)al;
byte[] buffer = new byte[1024];
buffer = objecttobytearray(o);
s.Send(buffer);
byte[] buf = new byte[1024];
Object obj = new Object();
s.Receive(buf);
obj = bytearraytoobject(buf);
ArrayList qal = (ArrayList)obj;
int i = 1;
foreach (Object ob in qal)
{
Console.WriteLine("\t[{0}]:\t{1}", i++, ob);
}
Console.WriteLine();
Console.ReadLine();
}
static byte[] objecttobytearray(Object obj)
{
if (obj == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, obj);
return ms.ToArray();
}
static Object bytearraytoobject(byte[] buffer)
{
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
ms.Write(buffer, 0, buffer.Length);
ms.Seek(0, SeekOrigin.Begin);
Object obj = (Object)bf.Deserialize(ms);
return obj;
}
}
}
|
|
|
|
|
I have researched adding a MessageBox to an application. However the sealed class does not give you much. The solution is always to create your own.
I figure you could use the Win32 Version and import it into C#. but that does not take care of the background color. in MFC you call setdlgBackColor or something like that and the entire application is converted to the new color (skin).
in C# you do not have that. is this exposed in VB.NET? I was thinking I could link in a VB.NET DLL with the functionality.
still there are several dialogs in windows that act this way. one of them is the fileopen dialog.
does anyone have an elegant solution that does not involve recoding the entire functionality, LOL, of the dialog / MessageBox in question? there are many people on the web running into this problem, especially if they are skinning their apps or providing custom colors for customer requirements.
Thanks
-Pete
|
|
|
|
|
|
This is a great Article - Thanks!
I could not figure out how to change the background color though.
I did not see anything in the code of the project that allowed you to do that.
-Pete
|
|
|
|
|
peterdrozd wrote: I could not figure out how to change the background color though.
You could try posting your question on the article forum to see if the author has any idea. I suspect you may find it quicker just to use a custom dialog with all your own controls and formats.
|
|
|
|
|
You must have to write a custom control to do that...
|
|
|
|
|
Can anyone suggest me an open source and/or commercial winform control to display multi colored/format textbox (just like RichTextBox).
It doesn't need to be capable of doing syntax highlighting. Just enough to be able to manually format the text I append to it. I intend to use as a textbox to display process logging which every occurence of different info/status to be logged/appended to the textbox in different format (text color, bgcolor, bold, italic). E.g: Error message to be hilited red and bold.
I've tried using RichTextBox but when the text in it becomes large, it becomes noticeably slow to update the text.
Thanks
|
|
|
|
|
Ajakblackgoat wrote: I've tried using RichTextBox but when the text in it becomes large, it becomes noticeably slow to update the text.
That could grow to a large amount of data, and manipulating large amounts of data costs time. Swapping out the control won't bring much, as it still has to work with a large collection of data.
Substitute it for a textbox. It'll take a bit longer, but even that one will become slow eventually.
As an alternative; you could keep the list in a non-visual component, and only display the top 50 entries from that list.
--edit--
Luc's solution would be the better option; not only due to it's better performance, but also because you wouldn't need to cache things yourself
I are Troll
modified on Friday, January 8, 2010 8:37 AM
|
|
|
|
|
|
Thanks for your reply.
Rich text box control is a full featured control supporting rtf formatting which I do not need in what I want to achieve. I have seen textbox control in some application (such as regexbuddy & powergrep) which does what I need and it's very fast in displaying 100MB++ of text data complete with highlights and formatting. And I believe it's not richtextbox.
So I'm looking for something similar...
|
|
|
|
|
Ajakblackgoat wrote: it's very fast in displaying 100MB++ of text data complete with highlights and formatting. And I believe it's not richtextbox.
It's not the control that makes it fast, it's the way they handle loading. Doing formatting and highlighting on 100Mb+ costs time, but you don't have to highlight what you cannot see. I'd also imagine that such applications load the parts that they're actually working with, as opposed to loading the entire file into memory.
Still, the ListBox would be the way to go. My proposition may sound simpeler, but it really isn't. You'd always be manipulating a large (immutable!) blob of text that's somewhere in memory, while you'd be adding items to a collection if you're using a ListBox.
Further, a ListBox would paint the items that are actually visible, so you wouldn't have to format and highlight 100Mb at a time. You might have to spend some time on owner-drawing[^], but I think it's worth it
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: It's not the control that makes it fast, it's the way they handle loading. Doing formatting and highlighting on 100Mb+ costs time, but you don't have to highlight what you cannot see. I'd also imagine that such applications load the parts that they're actually working with, as opposed to loading the entire file into memory.
Richtextbox doesn't handle it the same way?
Eddy Vluggen wrote: Still, the ListBox would be the way to go.
But still it lacks textbox-like select & copy functionality. I've already done ownerdrawn listbox for other projects, so you don't have to keep pushing me to use it. I know what it's limitation which hinders me from using it for this particular app.
Perhaps I didn't post my question clearly. I was asking if anyone had come across a control which does the same, not how to do it.
|
|
|
|
|
Ajakblackgoat wrote: Richtextbox doesn't handle it the same way?
Nope, a RichTextBox works with a large string that contains all it's data. It's like loading a large textfile into Notepad all at once. One has to read all the characters and count the returns to find line #40.
Ajakblackgoat wrote: But still it lacks textbox-like select & copy functionality.
It doesn't do that out of the box, you're right there. It would still be easier to add that, then to try and outperform it with a RTB.
Ajakblackgoat wrote: I know what it's limitation which hinders me from using it for this particular app.
The limitation is that you can't edit the items directly. If there's a lot of items being put into that component, then you won't have much chance of typing anyway.
Possible solutions would be showing an RTB on the place of the ListBoxItem (as Luc suggested), or a pop-up screen with details.
Ajakblackgoat wrote: Perhaps I didn't post my question clearly. I was asking if anyone had come across a control which does the same, not how to do it.
You're looking for a fast, editable list? I guess that there should be one or two out there
I are Troll
|
|
|
|
|
When the data is line-oriented, as in logging, I always use a ListBox, not a TextBox, since ListBox is line-oriented and scales well; TextBox and RichTextBox require all text to be concatenated and hence slow down when the amount of text increases.
ListBox has an OwerDrawn mode that enables you to paint the items any way you like, look here[^] for an example.
|
|
|
|
|
Thanks for your suggestion.
I already did listbox as my output log control for one of my apps and it serves just fine for that particular type of scenario.
But I need something that supports wrapping to cater longer text such as .net error messages, and user can select text and copy to clipboard (just like textbox), which I think will be tedious if possible to do with ListBox.
|
|
|
|
|
Ajakblackgoat wrote: which I think will be tedious if possible
Not at all. It depends on the details of course, but it is very easy to:
- have arbitrary length text in each item (DrawString can word-wrap text)
- variable height items (OwnerDrawVariable), which adds a MeasureItem event to determine height (with Graphics.MeasureString)
- intercept CTRL/C to get your ToString() representation of an entire item
It would get somewhat more complex if you also need to copy selectable parts of an item.
FWIW: you can add controls to a ListBox item, so you could have a (Rich)TextBox inside each item, however I would not do that, as the lightweight approach is easy enough and much cheaper resource wise.
|
|
|
|
|
I need to create a taskbar in the mdiform just looks like windows taskbar..... when i open a form the name should be displayed in the taskbar when i minimize it should hide on the taskbar....
|
|
|
|
|
how to set default user selected icon for windows application while deploying the windows application. when i installed my deployed win application i am getting default type(file) icon for installed application. can any one suggest step how to do............
|
|
|
|