|
hi to all,
I am working in windows DatagridView,i assigning value through the Datasource, but in the grid also having the combo box where values are populated from the dataset. At the runtime, if i am click the grid, it throws the error like ='Datagridviewcomboboxcell value is not valid' .
Anyone can help me!!!
Regards
srikanth
|
|
|
|
|
|
Hi Team,
I have two textboxes for taking startdate and enddate.
If I give start date 10/01/2009 and Enddate 10/12/2009 then report should display 01st - 12th Oct'09
If start date is 10/02/2009 then it should display 02nd -12th Oct'09
Kindly help me
|
|
|
|
|
This question connect to other post
Date Time String formats[^]
String str1 = DateTime.Now.ToString("dd");
String str2;
if (str1 == "01")
str2 = "st"
else if (str1 == "02")
str2 = "nd";
else if (str1 == "03")
str2 = "rd";
else
str2 = "th";
String str3 = DateTime.Now.ToString("MMM");
String str4 = DateTime.Now.ToString("yy");
String date = str1+str2+ " " + str3+ "'"+ str4;
This task is dead easy. I showed how i did get custom format. Normal string formating doesn't show "st, nd, rd, th" (At least I think that whay) and doesn't allow chars as "'"
Edit: Pre tags added
|
|
|
|
|
Instead using else if I prefer using switch .
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
i woud use else if because it is small code. I would use Switch for bigger operation
|
|
|
|
|
I prefer switch for small and bigger cases.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
SqlConnection thisConnection = new SqlConnection(<br />
@"Server=(local);Integrated Security=True;" +<br />
"Database=northwind");<br />
NOW the server is "local",but when i Install my Program on pc1,install DATABASE on pc2,how can i use date from pc2? i can not change server everytime,i think it can read from a comboBox?how can i do?
|
|
|
|
|
You could build the connection string dynamically depending on which server you want to use.
If this answer makes no sense to you, please elaborate your question 
|
|
|
|
|
if you use "pc2" instead of "(local)" your app will work what ever machine it is running on. Better to hold the connection string in a config file and provide a means to configure it within your app.
|
|
|
|
|
if you are running program on pc1 and installed database on PC2 then you shoud use connection string as below.
SqlConnection thisConnection = new SqlConnection(
"Server=pc2 IP or pc2 Name;Integrated Security=True;
Database=northwind");
|
|
|
|
|
You can use DataLink to create connection from any workstation to database server...code snippets like
MSDASC.DataLinks ObjDLink;
ObjDLink= new MSDASC.DataLinks();
ObjPrompt = ObjDLink.PromptNew();
strConnectioString = ObjPrompt.ToString();
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
My offer ,else use MSDASC class
now see what is my offer..
1- Server side:
Run Sql Server browser Service in your database server machine, then
create Valid login for your database,set sql server authentication to Windows and SQL athentication
2- Application side:
with a form like this:
http://privateimage.com/images/9fq89vuk7uokjz8koz.jpg
and with functions like below for buttons
private void btnSearch_Click(object sender, EventArgs e)
{
SqlDataSourceEnumerator SqlEnumerator = SqlDataSourceEnumerator.Instance;
DataTable dt = new DataTable();
dt = SqlEnumerator.GetDataSources();
dataGridView1.DataSource = dt.DefaultView;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count != 0)
{
string ConString = "";
SqlConnectionStringBuilder builder =new SqlConnectionStringBuilder();
builder.ApplicationName = "MyApp";
builder.WorkstationID = Environment.MachineName;
builder.UserID = txtLoginName.Text.Trim();
builder.Password = txtPassword.Text.Trim());
builder.InitialCatalog="MyDBName";
builder.DataSource = dataGridView1.SelectedRows[0].Cells["ServerName"].Value.ToString()+
"\\"+dataGridView1.SelectedRows[0].Cells["InstanceName"].Value.ToString();
ConString = builder.ConnectionString;
}
}
at the end your data link string is ConString variable, you can store it in encrypted file or registry. each time application start check stored connection, and if failed retry this form
note: used namespace are:
using System.Data.Sql;
using System.Data.SqlClient;
hope helps with ugly sample
modified on Friday, December 25, 2009 9:45 AM
|
|
|
|
|
I'm attempting to create several ComboBox controls on a windows form that are all connected to a relational database. The controls "narrow" their selection choices when any other given ComboBox is selected to an item.
Similar to say..narrowing down a motherboard model by selecting Intel/AMD --> Socket --> Chipset --> etc. As I'm quite new to working with data in C#, I was hoping someone could offer a good reference that I can use to read up on this - preferably, a beginner's reference.
Help is appreciated. =]
|
|
|
|
|
Hi Team
I need to show date in this format in my report -----------Dec'09
I am getting format like this Dec2009 for this I am using (MonthName(Month(Parameters!sdate.Value),TRUE)& Year(Parameters!sdate.Value))
Please kindly help me how to get format Dec'09 and also
How to display previous month date also Nov'09 (Need formula)
|
|
|
|
|
String date = DateTime.Now.ToString("MMM yy");
However it will return exception if you want " ' " char to be seen.
siddisagar wrote: How to display previous month date also Nov'09 (Need formula)
String date = DateTime.Now.AddMonths(-1).ToString("MMM yy");
|
|
|
|
|
I am using Sqlite in an application.
Was wondering if anybody knows limitations on the number of characters one can have when labelling a column as being of type(/affinity) TEXT?
|
|
|
|
|
I think you mean how uch data such a column can hold.
As found by using Google : http://www.sqlite.org/limits.html[^]
For your info, the google search (sqlite max text) gave me this hit in a thread referred to on the first result-page...
Nah... What's up, Doc?
CCC's solved : 1
If a bus station is where a bus stops, and a train station is where a train stops, why do I have a work station on my desk?
|
|
|
|
|
I am writing a c# program that uses property grids. The problem is that for some reason they are displayed in the basic graphics version, the scroll bars are the standard old grey version. The version that you got in windows 95 (i think), or if you turn on the classic theme in windows.
I beleve that the issue is with my current project because when i make a new project, and put a property grid on the form, its scroll bar are displayed correctly, in the current windows theme.
does anyone know how to fix this for my current project?
|
|
|
|
|
Hi,
AFAIK you need to call EnableVisualStyles() once to get the modern look of Controls, as in:
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
|
|
|
|
|
|
I am converting a class from VB to C# so that it can be compiled into the same assembly, but have run into something that I don't know how to handle. The class is a generic ObservableDictionary<tkey, tvalue="">. My problem is that I don't know how to implement both System.Collections.Generic.IEnumerable.GetEnumerator and System.Collections.IEnumerable.GetEnumerator since both of them need an exposed function named GetEnumerator().
The VB code is as follows:
Public Function GetEnumerator()
As System.Collections.Generic.IEnumerator(
Of System.Collections.Generic.KeyValuePair(Of TKey, TValue))
Implements System.Collections.Generic.IEnumerable(
Of System.Collections.Generic.KeyValuePair(Of TKey, TValue)).GetEnumerator
Return DirectCast(Dictionary, IDictionary).GetEnumerator()
End Function
Private Function GetEnumerator1()
As System.Collections.IEnumerator
Implements System.Collections.IEnumerable.GetEnumerator
Return GetEnumerator()
End Function
It looks to me like the VB code is renaming the GetEnumerator function to GetEnumerator1 and explicitly mapping this back to the GetEnumerator function that is being implemented, but I have never seen anything like this in C#.
Is this possible in C#?
|
|
|
|
|
Yep. I was going to type it all out, but that's a lot of typing... Heh
VB:
Public Function DoSomething() Implements A.B.C.DoSomething
End Function
C#:
public void A.B.C.DoSomething()
{
}
EDIT: There's a shortcut, by the way... Right-click the interface in the class definition, and pick "Implement Interface Explicitly"
|
|
|
|
|
I was working on conflation .... and I have 25 text boxes .. I collected this strings on an array ... But It becomes a headache for me to compare the 25 strings , and if there are similar strings I want to know how many different strings are there..... the frequency and in which index they are found ... I couldn't have the idea of the algorithm to do that ... Please just show me the algorithm and I will work out the rest my self ...
Thank you
|
|
|
|
|
Maybe you should sort them first and then your comparisons will be somewhat easier, as you can find groups without having to do repeated compares.
|
|
|
|