|
You're welcome!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Hi all,i have a question about methods...
i want to write a method to connect my database and return a result like:
select * from mytable
and show it in a gridview control
how can i do it???
thank you... 
|
|
|
|
|
You haven't stated what database you want to connect to. This article[^] describes the steps to connect an SQL Server database and will help you get started.
|
|
|
|
|
thank you...
i want to connect sql server database,
i have a class and in my class i defined a method to to execute a query in my database and returns result,
and i have a gridview control on my main form to show this result.
this is my code:
class:
public class CustomerClass
{
SqlConnection con = new SqlConnection("server=(local);database=Tailor;integrated security=true;");
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
public CustomerClass()
{
}
public object selectCustomers()
{
con.Open();
SqlCommand select = new SqlCommand("select * from Customers",con);
select.ExecuteNonQuery();
con.Close();
da.SelectCommand = select;
da.Fill(ds, "Customer");
return ds.Tables;
}
}
form load:
CustomerClass test=new CustomerClass();
object test2 = test.selectCustomers();
dataGridView1.DataSource = test2;
|
|
|
|
|
So, what is your problem?
|
|
|
|
|
Do a little more searching... there are plenty examples around this site, for example:
How to populate DataGridView, GridView with SQL statement in C#[^]
In general, use code similar to this in your method:
string strSQLconnection = "Data Source=dbServer;Initial Catalog=testDB;Integrated Security=True";
SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
SqlCommand sqlCommand = new SqlCommand("select * from mytable", sqlConnection);
sqlConnection.Open();
SqlDataReader reader = sqlCommand.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
|
|
|
|
|
See here[^] on how to connect to the database. The returned DataSet can be bound to a grid, which will show the results.
If you're working with SQL Server, you might want to have a look at LINQ to SQL.
|
|
|
|
|
I am stuck with regular expressions. In fact, I want the 'T' to be optional, and I got a working example:
string text = "123T234";
Regex regex = new Regex(@"([0-9]{3})[T]?([0-9]{3})");
Match stuff = regex.Match(text);
Now, why doesn't
Quote: ([0-9]{4})-([1-9]|[1][0-2])-([0-2]?[0-9]|[3][0-1])[T]?([0-1]?[0-9]|[2][0-3])[:]([0-5]?[0-9])[:]([0-5]?[0-9])?.?([0-9]{1,6})[Z]?([+-]?[0-9][\.|,]?[0-9]?|[0-9]{2}?|[+-]?[0][1][0-2][\.]?[0-9]?|[0-9]{2}?)
produce a match for
2014-02-01T14:12:33Z+1
?
Any help is greatly appreciated.
[Solved by Original Griff]
Clean-up crew needed, grammar spill... - Nagy Vilmos
modified 6-Feb-14 5:45am.
|
|
|
|
|
Because the Month group explicitly excludes it:
([0-9]{4})-([1-9]|[1][0-2])
Try:
([0-9]{4})-(0?[1-9]|[1][0-2])
BTW: [0-9] is equivalent to \d which is a little shorter!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I don't want the T to be included in any group - Wouldn't
OriginalGriff wrote: (0?[1-9]|[1][0-2])
allow months to be 0?
Maybe I am just slow, but I don't get why the solution should allow the 'T' to be missing?
Clean-up crew needed, grammar spill... - Nagy Vilmos
|
|
|
|
|
No, because it is an optional '0' followed by a non-zero digit, or a '1' followed by a '0', '1', or '2'.
'0' on it's own isn't allowed, nor is "00"
The '?' after the 'T' specifies "zero or one" instances, so it works with or without it.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I sometimes feel blind
Many thanks for the help
Clean-up crew needed, grammar spill... - Nagy Vilmos
|
|
|
|
|
You're welcome!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I want to develop a tool that will assess the quality of a video. I did some R&D on this and found an interface called "IQualProp", that is part of DirectShow API. I am not trying to get a sample code in C# on how to use this interface, but i am not finding anywhere. There are samples in c++ to use this "IQualProp", but not in C#. Any help on this will be great.
|
|
|
|
|
I suspect that IQualProp is only available with MFC, and thus C++.
C# has something similar for sure, but I can't say what it is.
Source[^]
Clean-up crew needed, grammar spill... - Nagy Vilmos
|
|
|
|
|
Again, how do you define "video quality"?? You have yet to define this and this is your second question on the subject.
IQualProp only returns the performance properties of a video renderer. It has nothing to do with the video signal itself.
|
|
|
|
|
Thank you for the reply.
A video without any stuck that runs smoothly is quality of video for me. I want to play a video (recorded video) and check whether it runs properly without stuck. If there is any stuck in video I want to throw a error that quality of the video is not proper. Please correct me if im wrong in understanding the quality/performance of video.
IqualProp interface has a method called "get_Jitter" which will give the variation in a video. So, I was thinking this can be of help for me.
Please guide me.
|
|
|
|
|
OK. Too bad that interface has absolutely nothing to do with the quality of the video.
That interface will give the performance stats of the video renderer, not the video itself. There is also no correlation between the renderer performance and the size of the video. The values that you get are the current moment in time performance of the renderer and are also affected by the current system load. Run through the video again and you can get different numbers.
You can play a 320x200 at 30 frames a second and still get jitter, then play a 1080p video and get none. This is not an indicator of anything related to the video.
|
|
|
|
|
How can I tell the difference between source and published .NET code?
I am looking at some inherited code that I have not touched in about a year. The original designer had me first publish locally before uploading the published code to the internet server. Now I am looking a number of backed up source folders as well bas backed up published folders. I should have done a better job at naming the folders, I guess. Now I wonder: How can I tell the difference between source and published .NET code? Is there some easy way to see if some folder that contains only published code is lacking a file or xml setting?
Is the .csproj file or the .sln file part of the code pushed to the server when you publish?
|
|
|
|
|
Published code contains only the files needed for the app to run and it does not contain .csproj or .sln files.
|
|
|
|
|
Hm... Normally, the web server won't throw an exception if csproj and sln files are deployed also...
|
|
|
|
|
Well, no - but it's not automatic. (And I'd rather not do it, it's untidy and prone to error)
I'd probably include a version number and a build timestamp, as I do in my non-website code.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Yes, it wouldn't. I meant to say that when you publish your code using Visual Studio, it doesn't copy the .csproj and .sln files.
|
|
|
|
|
Xarzu wrote: Is the .csproj file or the .sln file part of the code pushed to the server when you publish?
When I deliver something to production it is
- In source control
- Labeled in source control
- Built from source control
- Delivered from that build
Other than that I either keep track of the label that went to production and when.
Or I specifically re-label using a build version number with a label that indicates a production delivery.
|
|
|
|
|
I am adapting a XAML Control to be MVVM compliant. Right now the XAML is actually not important, but there is one component that is giving me grief. The control is actually called from another view model on an event. Click here to add kind of thing. That command looks like this:
private void OnAddItem()
{
SubItemViewModel subVM = new SubItemViewModel(Key, null, false);
IDisposable ss = Observable.FromEventPattern(subVM.Save, "ExecuteEnd").Take(1).Subscribe(x => { LoadList(); });
SubControl ctrl = new SubControl();
ctrl.DataContext = subVM;
WorkspaceUserControlWindow w = new WorkspaceUserControlWindow(ctrl);
w.Title = subVM.DisplayTitle ?? Key.Value + " - Add Item";
Observable.FromEventPattern(w, "Closed").Take(1).Subscribe(x => { if (ss != null) ss.Dispose(); });
w.Show();
}
This worked fine in a non-MVVM model using a delegate command, click events, etc... Now that I have migrated the VM over to MVVM I need to understand how to publish the Save command so that the calling event can listen for the ExecuteEnd and reload the data list as shown here:
IDisposable ss= Observable.FromEventPattern(subVM.Save, "ExecuteEnd").Take(1).Subscribe(x => { LoadList(); });
I have always used relay commands within my view models as I have never needed to observe a command like this. Thoughts?
Cheers, --EA
|
|
|
|