|
I want to load in application dataGrid 3TIER with SqlDataReader and code of C#?
thanks
|
|
|
|
|
Hey, could you be more specific about what you are planning to do ?
|
|
|
|
|
I would like to fill my datagrid from sql database in accordance with the principles of the n-tier architecture (DAL,BLL,UI), but I do not know how to do it in connected mode
|
|
|
|
|
Not quiet certain on the above 'principles' but try this:
try
{
string query = @"SELECT * FROM [contacts]";
conn.Close();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = query;
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
DataSet dataset = new DataSet();
DataTable table = dataset.Tables.Add();
table.Columns.Add("contactid", typeof(string));
table.Columns.Add("firstname", typeof(string));
table.Columns.Add("lastname", typeof(string));
table.Columns.Add("email", typeof(string));
while (reader.Read())
{
table.Rows.Add(reader["contact_id"].ToString(), reader["name"].ToString(), reader["surname"].ToString(), reader["email"].ToString());
}
if (dataset.Tables[0].Rows.Count > 0 || dataset.Tables.Count > -1)
{
contacts.DataSource = table;
contacts.DataBind();
contacts.Visible = true;
}
}
catch (SqlException fc)
{
error.Text = "Error occured :" + fc.Message;
}
finally
{
conn.Close();
}
Later
|
|
|
|
|
|
Hello All,
I have problem with regular expression. i have one string can any tell the regular expression for that string.
String text = AAAA!1234,BBBB;11111/CCCCC:2222/
In this string.
I want
1)the string between ! and , as a "Jobid" means 1234
2)the string between ; and / as a "Field1" means 11111
3)the string between : and / as a "Field2" means 2222
Can any one tell the regular expression for that string.
Thanks
Bhaskar
modified on Friday, April 16, 2010 6:31 AM
|
|
|
|
|
Do you need a regular expression?
Something like this might do.
char[] splitChars = {'!', ',', ';', '/', ':'};
string[] theBits = text.Split(splitChars);
foreach(string s in theBits)
{
}
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
Thanks for ur reply,
I need the regular expression like this,
Regex rx = new Regex(@"(!(?<jobid>.*?),)(.*)(;(?<field1>.*?)/)(.*)( <field2>.*?)/)(.*)",RegexOptions.Compiled | RegexOptions.IgnoreCase);
in the above regular expression i am extracting the string based on the groups. but if one of the group is not present in the string. it is not matching.
example
"aaa!1234,BBBBCCCCC:222222/"
if the text is like this the regular expression is not matching.
|
|
|
|
|
To make a group optional, simply append the ? character to the group. This should do the trick:
@"(!(?<jobid>.*?),)?(.*)(;(?<field1>.*?)/)?(.*)(:(?<field2>.*?)/)?(.*)"
|
|
|
|
|
You can use a tool like Espresso to build your regular expressions. The link is http://www.ultrapico.com/Expresso.htm[^]
Here is the regex I came up with:
(?:!(?<JobId>\w*)(?:.*?),(?:.*?))?(?:;(?<Field1>\w*)?/??(?:.*?))?:(?<Field2>\w*)??/
Expresso will generate the following C# code for you:
<br />
<br />
public static Regex regex = new Regex(<br />
"(?:!(?<JobId>\\w*)(?:.*?),(?:.*?))?(?:;(?<Field1>\\w*)?/??(?"+<br />
":.*?))?:(?<Field2>\\w*)??/",<br />
RegexOptions.Multiline<br />
| RegexOptions.CultureInvariant<br />
| RegexOptions.Compiled<br />
);<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
I hope this helps. I wrapped each section in a non-capturing group with the ? option to account for cases where the field 1 may not be present.
|
|
|
|
|
5 from me!
I have been using Expresso for a year or so, and had never spotted it could generate the C# code! Admittedly, it's not an onerous job, but the comment generation is very handy! Thanks a lot - Friday has not been wasted for me: I've learned something new...
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Hello JTS
Thank u Very much, u helped me alot. once again thank u...
|
|
|
|
|
The best way you can ever sooth around validation expressions is to Try Me(Expresso)...
Good luck.
|
|
|
|
|
Hi
I am working on some software that needs to be able to create videos from an array of images and I need to create the video as fast as possible. The requirements I have been given are that the software needs to be able to create 6 minute video at 640x480 resolution and 25 fps within about 5 - 10 seconds. Can anyone give me any advice or help?
Thanx
|
|
|
|
|
I don't think that can be done, it amounts to generating 1000 frames per second.
|
|
|
|
|
That requers processing power of 0,77GB/s - 1,54GB/s (asuming the images in the video is in 24bit, and this is for "pure" image reading, any processing like resizing, image filters and so on must be added), you better whipe the dust from that old asm book and optimize like mad.
|
|
|
|
|
Ok thanx for the reply. Im not sure how to create video from images. Does anyone know of any example code I can look at?
|
|
|
|
|
all video is is a very fast slideshow.
Standard television FPS is 24, movies are 30.
"Don't re-invent the wheel." applies here. There are plenty of commercial (and some free) applications out there that can do this. I would seriously look at using one.
Look at movie maker or something like that, because taking an image, resizing it to the proper dimensions and resolution, saving its relative position and saving it along with the other images to a video format is a pain you probably never want to go through.
|
|
|
|
|
Maybe I should tell you more about the application im developing. Im working on a camera monitoring application that buffers video from up to 12 cameras and records events when a signal is recieved. The buffer is just an array of images that is saved to disk in 5 second chunks. So at the end of recording the event I need to create a video file from the images. I have some code that works and creates a video file but its far to slow. Im just wondering if theres anything faster. If you could point me at some code I could look at or just point me in the right direction it would be apreciated.
Thanx.
|
|
|
|
|
|
Hi,
For my application project I need to develop an IE plugin to show some custom file format (using OpenGL or DirectX, still not defined).
I search a long time on the Internet but I am not sure which technologie should I choose (and how to use it also, which may explain why I can not choose any ).
Would it be better to use an ActiveX or a "Brower Helper"?
Is there some samples somewhere how to do this in VS2008 C#?
I suppose I am not the first to ask this question...
Anybody an idea?
Thanks,
Risotto
|
|
|
|
|
Will this[^] article help?
/ravi
|
|
|
|
|
Hi,
Yes it helps me to understand how to use a BHO. Thanks!
The only point is I still don't know how to create a region in the HTML page (using the tag <embed />) and connect it with a windows form of my BHO (which would be a custom viewer for 3D data).
Regards,
Risotto
|
|
|
|
|
Hi,
From datatable, how to get data with distinct values along with one condition. Its like type='S' and distinct on one columns(id).
Thanks in advance.
modified on Friday, April 16, 2010 4:14 AM
|
|
|
|
|
Could you please elaborate your question. Are "id" and "classid" primary keys in your tables - then they are of course unique.. If you made a query on tables with the "id" and "classid" as pKey's then the select distinct should help you out in the sql statement. Maybe I didn't really get your question though..
|
|
|
|