|
monuSaini wrote: I had define connection string using wizard.
*shudder*
Don't! Learn how it works and don't rely on wizards.
Somewhere there should be generated code that contains the connection string. Alter that to get the connection string from the config file.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
hi all,
how to add data from database table to the combobox,
where i want to read a certain feild and when selected an other feild would be written in somewhere else
|
|
|
|
|
Which technology are you using: Windows Forms, ASP.net, WPF or other?
|
|
|
|
|
costavo wrote: how to add data from database table to the combobox,
where i want to read a certain feild and when selected an other feild would be written in somewhere else
SqlConnection dbConn = new SqlConnection ("connectionstring");<br />
dbConn.Open ();<br />
SqlDataAdapter da = new SqlDataAdapter ("SELECT town FROM Table", dbConn);<br />
da.Fill (ds);<br />
<br />
DropDownList1.DataSource = ds.Table[0];<br />
DropDownList1.DataBind ();
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
You can also check my reply here[^].
Hope it helps.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
in addition to the reply of Micheal sync
u also have to set the display member and value member properties.
set the display member to the field which u want to show.
and set the value member to the field which u want to display at some place else.
and on selectedindexchanged event set show your selected value ...
|
|
|
|
|
please would u give a code example
regards
|
|
|
|
|
costavo wrote: please would u give a code example
As I replied here,[^]
<br />
SqlConnection dbConn = new SqlConnection(connectionString);<br />
<br />
dbConn.Open();<br />
<br />
SqlDataAdapter da = new SqlDataAdapter("SELECT town,postal FROM table1", dbConn);<br />
DataSet ds = new DataSet();<br />
da.Fill(ds);<br />
<br />
dbConn.Close();<br />
<br />
DropDownList1.DataSource = ds.Tables[0];<br />
DropDownList1.DataTextField = "town";<br />
DropDownList1.DataValueField = "postalcode";<br />
DropDownList1.DataBind();
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
I have a WPF problem, namely my GUI top level exception handler doesn't:
<br />
public partial class ApplicationWindow : System.Windows.Window<br />
{<br />
public ApplicationWindow()<br />
{<br />
InitializeComponent();<br />
AppDomain.CurrentDomain.UnhandledException += <br />
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); <br />
}<br />
<br />
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)<br />
{<br />
}<br />
}<br />
* The code that I've removed from here works when CurrentDomain_UnhandledException is called sucessfully. Also I have try catches round all my top level execution blocks.
The problem I get is intermittant, and has only happened on the live machines . When I look at the event log, the CurrentDomain_UnhandledException isn't called (there is no event log entry), but I get a .net 2 runtime error:
EventType clr20r3, P1 gui.exe, P2 1.0.2768.23782, P3 46af354c, P4 system.servicemodel, P5 3.0.0.0, P6 4545a17d, P7 109, P8 b0, P9 2ekkxphpp1te4kvupcgmdwsnjepb3jzg, P10 NIL.
I know the error must be from WCF which is referenced by the GUI and have put pretty decent exception trapping in my client code. I really need to know how to capture the execption at the top level in the GUI (have I missed anything?).
Thanks.
|
|
|
|
|
Hi,
I just install directX 9.0b and using VS 2005 but I cannot build any of the directX demo projects found on this site. I have the following error amoung others
The type or namespace name 'DirectX' does not exist in the namespace 'Microsoft
after installing DirectX is it necessay to set a path to it??
Thanks.
Samuel
|
|
|
|
|
Install DirectX SDK from Microsoft. Add the needed reference to your project. Then add namespace you need to compile it. If you are using VS2005, then just mouse over unknown class, then click at the small box "using DirectX.xxx.xxx.xxx", then namespace will be added automatically.
|
|
|
|
|
I have never worked with DirectX but just to be sure for others: When you say you installed DirectX, what is it that you installed exactly? The runtime or the SDK? If you didn't install the SDK, there is no chance that any DirectX project will work (I think!)
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hi,
I'm experimenting on UPnP in Windows Vista Ultimate with Media Center. I've set up a few UPnP AV media servers and could connect to the data from Windows Media Player. But in Media Center I could only browse local files and no files from other UPnP servers.
That's why I'd try to write a C# UPnP client, that uses ALL available AV servers and not only the local storage in Vista MCE.
I've found out there are Intel tools für UPnP, but they are written in C. There is also UPnP support in Platform SDK CE, but I'm using UPnP on a standard PC.
I did not find any UPnP clients in C# here on codeproject. Maybe I've overlooked one in the results or someone of you knows some good external links on how to build a UPnP client in C# (without manually writing the protocol).
Thanks in advance,
Norbert
|
|
|
|
|
The Intel tools have C# stuff too the last time I looked. I didnt work on my router though, so I had to write on myself.
|
|
|
|
|
Alternatively you can import the UPnP COM library in Windows, and use that.
|
|
|
|
|
Hello everyone,
I am wondering if I am using TCPClient class in C#, how to setup timeout value? Timeout I mean, when connects to server for the 1st time, and during <timeout> interval, if no server response is received, the GetStream method will return will return other than wait forever.
thanks in advance,
George
|
|
|
|
|
Hey Guys, whats going on ? I want to check the the way I connect to sql and see if there's a more professional way, so please bare me !!! thanx
First I declare my SqlConnection, SqlDataAdapter and DataSet
SqlConnection InstConn = new SqlConnection();<br />
SqlDataAdapter InstDA = new SqlDataAdapter();<br />
DataSet DS = new DataSet();
then i create my Command text (Select, delete or update)
SqlCommand ChkCmd = new SqlCommand();
for selection then I fill my data set
InstDA .Fill(DS , "Table Name");
and if its Insert Delete or edit I use
ChkCmd .ExecuteNonQuery();
Not to mention that for edit I use SqlParameter.
so what do you think ? Is there a better way for doing this ?
and I also have another question, how can I prevent users from manipulating my database by entering some SQL command in a text box ! I know in ASP.net It authomatically prevent this, is this the same in C# Win or we have to manually do the same thing ?
Thanx
Mr.K
|
|
|
|
|
|
Does anyone know how i can vertical align the lines in a richtesxtbox? pls help
|
|
|
|
|
I am trying to draw a rubberband rectangle using one of the methods suggested in this forum. My problem is: after drawing the rectangle, if I move another window (for example a messagebox) over the rectangle (ruberband rectangle drawn earlier) part of this rectangle is not getting pained properly. Any help is highly appreciated.
The code that I am using is given below.
<br />
<br />
using System;<br />
using System.Windows.Forms;<br />
using System.Drawing;<br />
<br />
namespace RubberbandShape<br />
{<br />
class MainForm : System.Windows.Forms.Form<br />
{<br />
public MainForm()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
void InitializeComponent() {<br />
this.button1 = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.button1.Location = new System.Drawing.Point(323, 256);<br />
this.button1.Name = "button1";<br />
this.button1.Size = new System.Drawing.Size(75, 23);<br />
this.button1.TabIndex = 0;<br />
this.button1.Text = "button1";<br />
this.button1.UseVisualStyleBackColor = true;<br />
this.button1.Click += new System.EventHandler(this.button1_Click);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(401, 282);<br />
this.Controls.Add(this.button1);<br />
this.Name = "MainForm";<br />
this.Text = "Rubber Band Shape Drawing";<br />
this.Paint += new System.Windows.Forms.PaintEventHandler(this.MainForm_Paint);<br />
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseUp);<br />
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseMove);<br />
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseDown);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
<br />
[STAThread]<br />
public static void Main(string[] args)<br />
{<br />
Application.Run(new MainForm());<br />
}<br />
<br />
private bool mouseDown = false;<br />
private bool mouseMoving = false;<br />
private bool haveRect = false;<br />
private int XDown;<br />
private int YDown;<br />
private int oldX;<br />
private Button button1;<br />
private int oldY;<br />
<br />
void MainForm_MouseDown(object sender,<br />
System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
mouseDown = true;<br />
XDown = e.X;<br />
YDown = e.Y;<br />
mouseMoving = false;<br />
}<br />
else if( e.Button == MouseButtons.Right )<br />
{<br />
if( haveRect )<br />
{<br />
haveRect = false;
Invalidate();
}<br />
}<br />
}<br />
<br />
void MainForm_MouseMove(object sender,<br />
System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( mouseDown )<br />
{<br />
if( mouseMoving )<br />
RubberRectangle( XDown, YDown, oldX, oldY );<br />
RubberRectangle( XDown, YDown, e.X, e.Y );<br />
mouseMoving = true;<br />
oldX = e.X;<br />
oldY = e.Y;<br />
}<br />
}<br />
<br />
void MainForm_MouseUp(object sender,<br />
System.Windows.Forms.MouseEventArgs e)<br />
{<br />
mouseDown = false;<br />
mouseMoving = false;<br />
haveRect = true;<br />
}<br />
<br />
private void RubberRectangle( int X1, int Y1, int X2, int Y2 )<br />
{<br />
System.Drawing.Graphics g = Graphics.FromHwnd( this.Handle );<br />
<br />
RubberbandRectangle rect<br />
= new RubberbandRectangle();<br />
rect.DrawXORRectangle( g, X1, Y1, X2, Y2 );<br />
}<br />
<br />
void MainForm_Paint(object sender,<br />
System.Windows.Forms.PaintEventArgs e)<br />
{ <br />
Graphics g = Graphics.FromHwnd( this.Handle );<br />
<br />
if( haveRect )<br />
RubberRectangle( XDown, YDown, oldX, oldY );<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
MessageBox.Show("err yty");<br />
}<br />
<br />
} <br />
<br />
public enum PenStyles<br />
{<br />
PS_SOLID = 0,<br />
PS_DASH = 1,<br />
PS_DOT = 2,<br />
PS_DASHDOT = 3,<br />
PS_DASHDOTDOT = 4<br />
}<br />
public class RubberbandRectangle<br />
{<br />
private int NULL_BRUSH = 5;<br />
private int R2_XORPEN = 7;<br />
private PenStyles penStyle;<br />
private int BLACK_PEN = 0;<br />
<br />
public RubberbandRectangle()<br />
{<br />
penStyle = PenStyles.PS_DOT;<br />
}<br />
<br />
public PenStyles PenStyle<br />
{<br />
get { return penStyle; }<br />
set { penStyle = value; }<br />
}<br />
<br />
public void DrawXORRectangle(Graphics grp,<br />
int X1, int Y1, int X2, int Y2)<br />
{<br />
IntPtr hdc = grp.GetHdc();<br />
<br />
IntPtr gdiPen = CreatePen(penStyle,<br />
1, BLACK_PEN);<br />
<br />
SetROP2(hdc, R2_XORPEN);<br />
<br />
IntPtr oldPen = SelectObject(hdc, gdiPen);<br />
<br />
IntPtr oldBrush = SelectObject(hdc,<br />
GetStockObject(NULL_BRUSH));<br />
<br />
Rectangle(hdc, X1, Y1, X2, Y2);<br />
<br />
SelectObject(hdc, oldBrush);
SelectObject(hdc, oldPen);<br />
DeleteObject(gdiPen);
<br />
grp.ReleaseHdc(hdc);<br />
}<br />
<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern int SetROP2(<br />
IntPtr hdc,
int enDrawMode
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern IntPtr CreatePen(<br />
PenStyles enPenStyle,
int nWidth,
int crColor
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern bool DeleteObject(<br />
IntPtr hObject
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern IntPtr SelectObject(<br />
IntPtr hdc,
IntPtr hObject
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern void Rectangle(<br />
IntPtr hdc,
int X1,
int Y1,
int X2,
int Y2
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern IntPtr GetStockObject(<br />
int brStyle
);<br />
<br />
private static int RGB(int R, int G, int B)<br />
{<br />
return (R | (G << 8) | (B << 16));<br />
}<br />
}<br />
}<br />
<br />
Cheers,
Prasad
|
|
|
|
|
Don't paste your whole code. I don't think it will be read. Try to find out which part of it generates that problem and then ask for help in regards with that specific problem giving as an example your code fragment.
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
u must clear de background in the graphic object
void MainForm_Paint(object sender,<br />
System.Windows.Forms.PaintEventArgs e)<br />
{<br />
Graphics g = Graphics.FromHwnd(this.Handle);<br />
<br />
if (haveRect)<br />
{<br />
g.Clear(BackColor);<br />
RubberRectangle(XDown, YDown, oldX, oldY);<br />
}<br />
}
|
|
|
|
|
Cuciu,
Thanks for the suggestion. My problem is partially solved. Still the following problem persists. If I colse the messagebox, while it is on the rubber recatngle, that part is not redrawn.
Further, the suggested method doesn't work if I use "e.Graphics.Clear(BackColor)".
Could you please explain why?
My main problem is the Following:
<br />
private void FormMap_Paint(object Sender, PaintEventArgs e)<br />
{<br />
e.Graphics.Clear(this.BackColor);<br />
e.Graphics.DrawImage(Map.BMP, 0, 0);<br />
DrawFenceline();<br />
HiliteOn();<br />
}<br />
my Map object is stored on a bitmap. In form paint event I am drawing bitmap on to form. Then a fenceline is drawn (a region of rubberband lines) which is used to select a group of objects.
However, when I display a message box (or other form) on this form I am having problems with rubberband lines as explained earlier.
Any help to overcome this problem?
Regards,
Prasad
|
|
|
|
|
When you show your messagebox, call Invalidate() afterwards to force a paint event, which will draw your image again
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I know that GDI+ doesn't offer XOR drawing, but this still looks far too messy to me. What's wrong with just drawing a black ( or white, or whatever ), box in your paint event ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|