|
I already told you the only solution that might possibly work.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi i have added a combobox column to my datagrid and i want to populate it with integer list.how can i set data type of this column to hold integer values.
|
|
|
|
|
I understand you have set the DataSource of the DataGridViewComboBoxColumn, as well as its DisplayMember and ValueMember properties.
When you have done so, just set the ValueType property of it, like so:
((DataGridViewComboBoxColumn)dataGridView1.Columns[2]).ValueType = typeof(Int32);
Obviously, changing the name of dataGridView1 to your datagridview's name and the index (in this instance: 2) to the index of your combobox column.
Hope it helps.
var question = (_2b || !(_2b));
|
|
|
|
|
how should i place the datetimepicker in datagridview
using c# 2008
|
|
|
|
|
You'll have to be a little more vague with your question.
What do you want, what have you tried?
only two letters away from being an asset
|
|
|
|
|
i want to place a column, and for each cell in a row. will have a datetime picker control.
|
|
|
|
|
OK, what have you tried so far? Is this for ASP.NET or WinForms?
Create a template column and add the datetime picker.
only two letters away from being an asset
|
|
|
|
|
Sir, can u please suggest me for window application ?
|
|
|
|
|
|
hi,
i successful to create my 3 tier with the WCF method.(3 tier in coding and physical structure)
my project i divided into several layers.
myWCF(host), myClient(GUI/exe), myClientBz(Business Logic), myDAL(Data Access Layer), myClientInterfaces(interface)
Error, if call more than 1 host.
My Business Logic will more than 1 class.
And i intending to make interface to myDAL(data access layer)
setup config file in myWCF and myClient
Due to text limitation i only copy out the important part.
myHost config file: due to "<,>" allow not allow there, i change to "()"
(services)
(service behaviorConfiguration="metadataBehavior" name="myClientBz.myMessager")
(endpoint address="myMessagerService" binding="basicHttpBinding" bindingConfiguration="" name="basicHttp" contract="myClientInterfaces.imyMessager" /)
(endpoint binding="mexHttpBinding" bindingConfiguration="" name="metadataExchange" contract="IMetadataExchange" /)
(host)
(baseAddresses)
(add baseAddress="http://cspc/myMessager" /)
(/baseAddresses)
(/host)
(/service)
(/services)
myClient config file (i created by running the host exe, same time add service references at myClient's reference)
(client)
(endpoint address="http://cspc/myMessager/myMessagerService"
binding="basicHttpBinding" bindingConfiguration="basicHttp"
contract="myMessagerService.imyMessager" name="basicHttp" />
(/client)
Begin host:
using (ServiceHost host = new ServiceHost(typeof(myMessager)))
{
host.Open();
Console.ReadLine();
host.Close();
}
to test my exe are ok, i write form1 in myClient and test in other pc
myMessagerService.imyMessager proxy = new myClient.myMessagerService.imyMessagerClient();
string result = proxy.SendMessage();
MessageBox.Show(result, "xx");
it work fine. it return me a message that i write in myClient
If myClientBz required extra class, what needed in next?
Required to add myCaculation, myInformation into myClientBz.
Same i need to add interface for myCaculation, myInformation into myClientInterfaces right?
My project going to Touch on SQL DataBase.
which mean i required to add interface and config file(myDAL) again? or is depend how i write
the coding that the way i communicate with my SQL DB?
Please give advise or sample.
by memeber 2321293
CSTan
|
|
|
|
|
Can Someone please help me. I am trying to learn the use of datasets....
I can easily grab the data without a dataset from this table and apply the changes back to the sql server. But when I use the dataset I can only retrieve the data from sql server. Everytime I try doing the following C# Code to update the data in a sql server table stored in a dataset then apply the dataset back to sql server. The Environment comes back to me and complains.
Here Is the error I keep getting:
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
private void btnOptionSaveChanges_Click(object sender, EventArgs e)
{
SQLObjects MySQLObjects = new SQLObjects();
if (StandardProcedures.SQL_TestConnection(WhatIsMyConnectionString) == false)
{
MessageBox.Show("There is an issue with the application's connection string or ability to communicate with SQL Server! No Changes will be made.");
return;
}
if (!StandardProcedures.SQL_CheckToSeeIfTheObjectAlreadyExistsInSQLServer(WhatIsMyConnectionString, MySQLObjects.Table, "tblSoftwareControls"))
{
MessageBox.Show("tblSoftwareControls table does not exist in the Database. No Changes will be made");
return;
}
string sql = @"SELECT * FROM tblSoftwareControls";
SqlConnection conn = new SqlConnection(WhatIsMyConnectionString);
try
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.FillSchema(ds, SchemaType.Source, "tblSoftwareControls");
da.Fill(ds, "tblSoftwareControls");
DataTable dt = ds.Tables["tblSoftwareControls"];
DataRow dr;
if (dt.Rows.Count > 0)
{
dr = dt.Rows[0];
dr.BeginEdit();
dr["ConnectionString"] = txtApplicationConnectionString.Text;
dr["SplashScreenTimer"] = txtSplashScreenTimer.Text;
dr["VersionOverride"] = ckbxOverrideVersionByPass.Checked;
dr.EndEdit();
StandardProcedures.DebugLogWriter("Updated the record in tblSoftwareControls!");
}
else
{
dr = dt.NewRow();
dr["ConnectionString"] = txtApplicationConnectionString.Text;
dr["SplashScreenTimer"] = txtSplashScreenTimer.Text;
dr["VersionOverride"] = ckbxOverrideVersionByPass.Checked;
dt.Rows.Add(dr);
StandardProcedures.DebugLogWriter("Wrote a new record to tblSoftwareControls!");
}
SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(da);
da.Update(ds, "tblSoftwareControls");
StandardProcedures.DebugLogWriter("DataSet modifications or additions or deletions has the modifications applied to the SQL Server Table.");
}
catch (Exception ex)
{
StandardProcedures.ErrorLogWriter("Trying to populate the Options Tab: " + ex.ToString());
}
finally
{
conn.Close();
}
}
|
|
|
|
|
Ha... Thanks for the help but I figured it out....
The SQL Server table must have a primary key applied to one of the field for the above process to generate an update or delete procedure. Otherwise I would have to generate my own update or delete procedure and not use the above method.
|
|
|
|
|
Hi
I have built a named pipe service in wcf, but would like to run this in System Context rather than in User Context. Can someone advise me how to do this or point me to an example?
Thanks
|
|
|
|
|
Host it as a Windows Service and run it under the Local System account?
|
|
|
|
|
Sorry, but would you mind explaining to me how to do that?
|
|
|
|
|
Hello all,
I am using a DataGridView bound to a DataTable. How can I allow the user to type a letter on the keyboard and have the DataGridView change current row the first occurrence of a letter. For example, a column in the table is Lastname, so typing ‘S’ would bring you to the first Lastname that starts with an S.
I gather the best way would be to search the DataTable then use the result to set the DataGridView.
Note: column to search does not have a primary key as last name is not always unique.
Thanks in advance,
KCI
Get to work!
|
|
|
|
|
Use the LIKE operator from SQL. You might also be interested in the SOUNDEX function, that you can use to locate similar-sounding names
--edit--
JimSchor wrote: For example, a column in the table is Lastname, so typing ‘S’ would bring you to the first Lastname that starts with an S.
Aw, a new SQL-query on each keypress, my first advice wouldn't be very efficient. That means filtering the data that you already have - sort a View [^] that's based on your DataTable [^].
I are Troll
modified on Tuesday, September 29, 2009 5:01 PM
|
|
|
|
|
If you use a BindingSource to bind to your DataGridView , this (MSDN)[^] might help.
If not, this[^] article has some interesting ideas. It uses a DataGrid , not a DataGridView but there is a very similar example on MSDN for a DataGridView , I just cannot find it right now.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks for the advice, but I have tried these. Let me be a little more specific.
So far, I gather using dt.DefaultView may be the way to go since it does not require a PrimaryKey. And to note I am not using a bindingsource. My goal is to search the existing in memory rowset and not require another trip back and forth to the SQL server.
Here is a code snippet I tried, but it returns -1:
ds.Tables["Students"].DefaultView.Sort = "LastName";
int intRow = ds.Tables["Students"].DefaultView.Find("S%");
I have also tried this, but it returns zero rows:
ds.Tables["Students"].DefaultView.Sort = "LastName";
DataRowView[] drv = ds.Tables["Students"].DefaultView.FindRows("[LastName] LIKE 'S'");
Thanks,
KCI
Get to work!
modified on Wednesday, September 30, 2009 8:42 AM
|
|
|
|
|
Hello,
I have a question about the best way to Insert/Update a table that has around 117 fields.
I can create my own Insert/Update commands or use the CommandBuilder. Both of those need Parameters setup, but that's a lot of fields to setup.
Maybe I am missing something and there is a solution that I am not seeing.
Would it be easier to have a foreach loop and create the Insert/Update commands along with the parameters?
Any thoughts?
Thanks,
Chuck
|
|
|
|
|
I like to keep my tables a little less broad. Perhaps some normalization is in order?
Other than possibly using a DataAdapter you're stuck with creating the parameters. What would a for loop gain you?
only two letters away from being an asset
|
|
|
|
|
castrand1 wrote: I have a question about the best way to Insert/Update a table that has around 117 fields.
Well, there's two things here.
1 - the number of fields does not change the code
2 - your database design is dreadful to non existant.
castrand1 wrote: Both of those need Parameters setup, but that's a lot of fields to setup.
Yes, sometimes a programmer needs to actually write code. Terrible, it's true. Your core issue is your broken table design, however.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
castrand1 wrote: a table that has around 117 fields.
After putting in about 30 fields, did it occur to you that this may not be the best design??
|
|
|
|
|
Hello All,
I appreciate all the comments and yes, that database is bad and needs to be redesigned.
Let me explain what the table holds and maybe I could get some insight in how to best redesign it.
The table stores information about ships. These ships are of a tanker type ship, ones that hold crude oil, vegetable oil, etc.
Of all the fields in the table, most of the fields describe the ship, such as, dimensions, draughts, capacities, deadweights, etc. So, every ship will have unique values in the fields.
There are several fields that are relational. Hull Types, Owners, Classifications, Status, etc, other than that, all the other fields would hold unique values.
Thank you for your help,
Chuck
|
|
|
|
|
You can start by putting fields related to a subject about the ship in their own tables. Such as a ships navigation equipment goes in one table, hull information in another, engine information in another, ... You're not going to need every pipece of information about a ship all at once, so it's better break the data down into smaller logical blocks of related information and keep each block in its own table.
|
|
|
|