|
Hi all,
we have a table in sql server database.
We are using a data grid view control in our c# application.
How to retrieve and display a single record from the data base into the data grid view control.
Please suggest us at the earliest.
Regards,
Priya
|
|
|
|
|
I don't really understand the question. If you want to retrieve one record from the database, change your sql or stored procedure so that only one record is retrieved.
Wal
http://www.waleedeissa.com
|
|
|
|
|
Thanks for the response......
using datasource, dataset programatically in c# i want to retrieve the record from the sqlserver.
First I established the connection by connection string....
After that there is a problem in binding the data to the datagridview control.
Please suggest.
regards,
Priya
|
|
|
|
|
May I ask why you want to make it programamtically? DataSource controls weren't really meant to be used like that, they were created to make you write less code. BTW, what data source are you using, sqldatasource, objectdatasource ..etc? There're a lot of ways to retrieve data from a database, either by writing code, using a TableAdapter, using SqlDataSource .. etc, what exactly do you want to do?
Wal
http://www.waleedeissa.com
|
|
|
|
|
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(SQLQuery,ConnectionString);
DataSet ds = new DataSet();
da.Fill(ds);
now bind your datagrid view with your dataset's table
dataGridView1.DataSource = ds.Tables[0].DefaultView;
Note: write a SQLQuery that will return only those record that u want to show on grid
|
|
|
|
|
can sum1 plz suggest me sum website 4m whr 2 dwnload new namespaces of visual studio 2005? pls se4nd me the links...
|
|
|
|
|
namespaces are not downloaded! are you talking about assemblies?
Wal
http://www.waleedeissa.com
|
|
|
|
|
You mean the .NET Framework 2.0? Just type it on google.
And please use regular English instead of that garbage.
|
|
|
|
|
System.Text.Spk
Oh...wait...that's obsolete now as nobody understood it.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
What kind of language is that?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
but where are this messages stored? in one textbox? so how will user decide what is the name of file and which part of textbox text is to save?
or you simply want to save all the text from textbox but choose the file?
if so, make second textbox in which user will write the filename and save file like this:
StreamWriter msgStreamWriter = new StreamWriter(textBoxFileName.Text+".txt"); //with some validation if user written ".txt" or not
msgStreamWriter.WriteLine(textBox1.Text);
msgStreamWriter.Close();
if it is not a solution answer firts question
|
|
|
|
|
I am using a 3rd party library and tried to call a collection object. Worked fine in VB.NET but not in c#. in c# it asks to give an argument.Checking the definition in OBJECT browser, i found following:
VB.net:
Public Overridable Function Sessions(Optional ByVal item As Object = Nothing) As Object<br />
Member of: RepServerLib.IRepServer
c#:
public abstract new System.Object Sessions ( System.Object item )<br />
Member of RepServerLib.IRepServer
what the heck? why can't I use argument as OPTIONAL in c#? it drives me crazy. why is it not overridable in c#?
|
|
|
|
|
Hey don't take VBs abuse of good practice out on C#.
In pure OO terms, the VB version should actually be converted into 2 methods which would correspond to the following in C#:
public abstract object Sessions ()
{
return Sessions(null);
}
public abstract object Sessions(object item)
{
} The VB version is just syntactic sugar, and it does place some restrictions on VB code. Take this example:
Public Overridable Function Sessions() As Object
Public Overridable Function Sessions(Optional ByVal item As Object = Nothing) As Object Think about what would happen if you tried to call the no-parameter Sessions method. Not good is it?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
the issue is that the "Sesion" method returns a Collection list oBject. in VB.net, i can use "Count" method while count is alien for C#.
can you please tell em what should I do?
|
|
|
|
|
Cast the returned object to a collection, and you have the Count property available. The issue here though is that the Session should explicitly return a Collection if that is what is being returned. It shouldn't return an object and then rely on you to cast the object. Apart from anything else, this is going to result in unnecessary boxing/unboxing on this object.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Adnan Siddiqi wrote: why can't I use argument as OPTIONAL in c#? it drives me crazy. why is it not overridable in c#?
Because C# doesn't support optional parameters.
Cheers,
विक्रम
Be yourself, no matter what they say.
- Sting, Englishman in New York.
|
|
|
|
|
Hi there,
Is it possible to zip Files using C#?
eg,
I populate my listbox with files from my c drive using file uploader. The I want to take all those files amd Zip them into one Zip file then save them.
How can I do that?
|
|
|
|
|
This[^] article might help you with this. Alternatively, take a look at the SharpZipLib project.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Other than setting the PieSize propertoy to crMaximumPieSize , any idea how to make them bigger??
Crystal Report sucks isnt it??
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I have IBM printer, In the printer prop' I Have OVERLAYS.
this is table of files that I send To the flash Memory on the printer And I can choose
what file I whant to print.
How Can i change The Selection On the Printer controler???? BY CODE???
Can I Use Drivers of the Printer to see This Option???
|
|
|
|
|
Hey!
Does aynone know if it somehow is possible to get continous events when clicking (and not releasing) a button? Or if it is somehow possible to achieve this behavior in some other way?
The thing is that I want to use regular buttons for scrolling and if the user wants to scroll much he could just click and hold the button instead of clicking many times.
|
|
|
|
|
The only thing that springs to mind is to start a timer on the button down event, and on each interval, check to see if the mouse button is still down / still over the button, and if so, fire an event. If the mouse button is up / not over the button, stop the timer.
It's 0800hrs here, my brain doesn't get into gear until about 1000hrs, so there might be a much better way.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
Malcolm Smart wrote: It's 0800hrs here, my brain doesn't get into gear until about 1000hrs, so there might be a much better way.
For a starter, I think you don't need to check state of button, but simply stop the timer on mouse up event of the button. Other then that, your idea looks ok to me.
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
if you don't check button state, if user moves his mouse with mousebutton clicked the program will still behave like the button would be clicked.
Pawel
|
|
|
|
|
I stand corrected, MouseUp OR MouseLeave.
I still think it's better to use available events then setting up timer and checking manualy. Then again, it's quite possible that I am missing something, since I've been doing exclusively web dev lately.
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|