|
<br />
DataTable dt=ds.Tables["employee"];<br />
DataRow[] arr=dt.Select("emp_name='Joseph'");<br />
textBox1.Text=arr[0].ItemArray["emp_id"].ToString();<br />
Worth noting, if you have several persons named Joseph you simply can not take the first one.
To obtain uniqueness it is better to work with the id-column.
HTH
|
|
|
|
|
hi everyone,
i'm developing an application that will work like a web service. my problem is I don't know how to generate an http chunked response correctly. on the http chunked response, i'm getting a wrong size for my data size or chunk size. so i'm not sending the whole message. please advice :*(
|
|
|
|
|
I am using OleDBConnection to connect Access97 file. While connecting using wizard and clicking on testconnection button it shows an error "MSysAccounts table cannot open"
How can i connect to Access97 by OleDbConnection
Thanks In advance
Panal
|
|
|
|
|
<code>
string ms_connection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=;";
OleDbConnection mc_connection = new OleDbConnection(ms_connection);
string ms_sql = "select * from table";
OleDbCommand mc_command = new OleDbCommand(ms_sql, mc_connection);
OleDbDataReader rReader = mc_command.ExecuteReader();
rReader.Read();
</code>
or words to that effect
Web design and hosting
http://www.kayess.com.au
-- modified at 8:15 Friday 28th April, 2006
|
|
|
|
|
Hello,
Here is the code snippet that I am strucked at in converting a C# file to VB.NET. Can some one please help me here?
[DataObjectMethod(DataObjectMethodType.Select, true)]
static public List<roledata> GetRoles()
{
return GetRoles(null, false);
}
Thanks
-L
|
|
|
|
|
http://www.ragingsmurf.com/vbcsharpconverter.aspx[^]
<dataobjectmethod(dataobjectmethodtype.select, true)=""> _
Shared Public Function GetRoles() As List
Return GetRoles(Nothing,False)
End Function
'----------------------------------------------------------------
' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
' Developed by: Kamal Patel (http://www.KamalPatel.net)
'----------------------------------------------------------------
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Our Instant VB C# to VB converter produces:
<dataobjectmethod(dataobjectmethodtype.select, true)=""> _
Public Shared Function GetRoles() As List
Return GetRoles(Nothing, False)
End Function
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter and VB to C++ converter
Instant J#: VB to J# converter
Clear VB: Cleans up VB.NET code
Clear C#: Cleans up C# code
|
|
|
|
|
The attribute gets converted also, but this forum removes it due to its xml-like format:
"<dataobjectmethod(dataobjectmethodtype.select, true)=""> _"
I thought Christian's on-line converter omitted it, but it was also obviously the forum ...
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter and VB to C++ converter
Instant J#: VB to J# converter
Clear VB: Cleans up VB.NET code
Clear C#: Cleans up C# code
|
|
|
|
|
Wow - you can't even enter that format within a string literal - this should really be fixed.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter and VB to C++ converter
Instant J#: VB to J# converter
Clear VB: Cleans up VB.NET code
Clear C#: Cleans up C# code
|
|
|
|
|
Hi i was wondering if someone could help me with converting a string to a boolean so i can do an if statement.
what i'm wanting to do is like:
if (textbox4.text = "true")
{
}
but it gives me an error
thanks for you help in advance!
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
You need to have two = signs if you are comparing:
if(textBox4.Text == "true")
{
}
You can use bool.Parse() if you need to convert a string to a boolean:
<code>bool myBool = bool.Parse("true");</code>
Sean
|
|
|
|
|
Thanks alot guys to the both of you.
[way off topic]
Sean i tried to find a way to send you a PM or Email to thank you personally for helping me yesterday. The way you showed me with the listview worked. I just had a problem with the button! But when you was talking about the "Item properties" i was thinking as i was reading that "how in the heck does he remember all theese properties and such". Then it just dawned on me! listview1.items is the exact same thing as going to the properties manager for that control and changing it their. Your just doing the exact same thing but w/o the point n click!. It opened my eyes up to what was actually going on in the code! I was so happy after finding that out i drove home as fast as i could to try to send you a pm telling you thanks but there wasn't a way to do so.
but anyways man thanks alot for the help i really appreciate it!
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Good to see you got it working!
Glad to help
Sean
|
|
|
|
|
Single = is assignment
Double == is equality
if (textbox4.text == "true")
Boolean.Parse() to convert string to bool if needed
Sean just beat me to it by seconds!
-- modified at 21:26 Thursday 27th April, 2006
|
|
|
|
|
Sean
|
|
|
|
|
A good coding practice is to set your constant on the left side of your operator, so the compiler catches mistakes. For example:
if ( "true" == textbox4.text )<br />
{<br />
}
will assure that you never are doing an assignment if you forget an = when you are intending to do a comparison. It's a good habit to get into.
|
|
|
|
|
My list is not being written to the outFile and I can't seem to figure out why. I will post the code but I am not sure how to paste it correctly. Any Help would be appreciated.
using System;
using System.IO;
namespace Seating_Chart
/*Write a C# program that will read a list of student
* names from a text fileand assemble a seating chart
* onscreen.When the program is first run it should
* display an empty seating grid.Then you should be
* able to change the seating of any student. Such
* as Row 1, Seat 4 and change it's name to "John Doe".
* Any changes made should be immediatley written to
* the file.You must use more than one class. */
{
class Students
{
static void Main ()
{
string [,] Students = new string [5,10];
char answer = ' ';
int row = 0;
int seat = 0;
SeatChange NewSeatChange = new SeatChange();
StreamReader inStream = null;
StreamWriter outStream = null;
FileInfo inFile = new FileInfo (@"Student Seating Chart.txt");
FileInfo outFile = new FileInfo (@"Student Seating Chart.txt");
inStream = inFile.OpenText();
for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 10; y++)
{
Students [x, y]=inStream.ReadLine();
}
}
inStream.Close();
for (int x = 0; x < 5; x++)
{
Students [x, 0]=Convert.ToString(x);
}
for (int y = 0; y < 10; y++)
{
Students [0, y]=Convert.ToString(y);
}
Console.WriteLine ("Seat 1 2 3 4 5 6 7 8 9 10");
Console.WriteLine (" ----------------------------------------");
for (int x = 0; x < 5; x++)
{
Console.Write ("ROW " + (x + 1) + " ");
for (int y = 0; y < 10; y++)
{
Console.Write (" ", Students[x,y]);
}
Console.WriteLine ();
Console.WriteLine();
}
do
{
outStream = outFile.CreateText();
Console.WriteLine("Please enter the Row Number of the student you wish to move: ");
row = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please enter the Seat number of the student you want to move;");
seat = Convert.ToInt32(Console.ReadLine());
Students = NewSeatChange.Change(Students,seat,row);
for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 10; y++)
{
outStream.WriteLine(Students [x, y]);
}
}
outStream.Close();
Console.WriteLine ("seat 1 2 3 4 5 6 7 8 9 10");
Console.WriteLine (" ----------------------------------------");
for (int x = 0; x < 5; x++)
{
Console.Write ("ROW " + (x + 1) + " ");
for (int y = 0; y < 10; y++)
{
Console.Write (" ", Students[x,y]);
}
Console.WriteLine ();
Console.WriteLine();
}
Console.WriteLine("Would you like to move another student?");
answer = Convert.ToChar(Console.ReadLine());
}while(answer == 'y');
}
}
class SeatChange
{
public string [ , ] Change(string[ , ] Students, int a, int b)
{
Console.WriteLine("Please enter the students name:");
Students[a,b] = Console.ReadLine();
return Students;
}
}
}
Sorry this is so messy.
Shadow Sprite
|
|
|
|
|
Shadow Sprite wrote: My list is not being written to the outFile
Is there any exception being thrown? Did you try stepping through the debugger and seeing if the WriteLine method call actually executes?
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
No exceptions are being thrown when I run it. This is all new to me. When I try to step thru the program, I get stuck in the for loops. I am using Microsoft Visual C#. NET 2003/Visual C# Projects/Console Applications.
Thanks
Shadow Sprite
|
|
|
|
|
What is sequance to stop Backgroundworker?, what function to use to stop it?
|
|
|
|
|
|
Hi,
Should this be enough to draw a dotted rectangle on my form?
private void Form1_click(object sender, System.EventArgs e)<br />
{<br />
Rectangle r = new Rectangle(5,5,15,15);<br />
ControlPaint.DrawReversibleFrame(r, Color.Red, FrameStyle.Dashed);<br />
}
If not, what am I missing?
Thanks!
Mel
|
|
|
|
|
Only if your form happens to be where you draw the rectangle on the screen.
Perhaps you should ask about what you are trying to accomplish, instead.
---
b { font-weight: normal; }
|
|
|
|
|
Thank you, that makes sense. (I wasn't thinking and expected to see it at 5,5,15,15 on the form rather than the screen.)
Another question though. I'd actually like to use DrawFocusRectangle on a button, and did get it working yesterday, but after I changed a couple properties of my button (like tabstop #, size, and location), it stopped working. I added a MessageBox just before the DrawFocusRectangle call and after I hit the ok button, the focus rectangle did draw (code below). I also added a Click event (on some label) and moved the code below (without the MessageBox ) to the event, and then it worked too.
button2.Focus();<br />
int x = button2.ClientRectangle.Location.X + 3;<br />
int y = button2.ClientRectangle.Location.Y + 3;<br />
int w = button2.ClientRectangle.Width - 6;<br />
int h = button2.ClientRectangle.Height - 6;<br />
Rectangle r = new Rectangle(x,y,w,h); <br />
MessageBox.Show(""); ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(button2.Handle), r, Color.Black, Color.Black);
Anyone know why it won't work without some external help?
Thanks again!!!
Mel
|
|
|
|
|
You are calling the Focus event, I assume that this will redraw the control to reflect the changed status. That redraw will however not take place until you returned control to the system. Without the message box that will not happen until after you have drawn the rectangle, so it would just be drawn over.
When you show a message box that gives the control to the system. Calling DoEvents will have the same result.
However, just drawing on top of a control is not the well behaved way to change the apperance of the control. You should subscribe to the OnPaint event to do it properly. Then you don't have the problem that the rectangle disappears whenever the control is redrawn.
---
b { font-weight: normal; }
|
|
|
|