|
I've not used URI's a lot of late, but I just noticed that telling the Uri constructor:
System.Uri(string uriString, bool dontEscape)
in .NET 2.0 to not escape the string is depicted AND the function isn't even included in the framework > 2.0)
MSDN says to just use Uri(string uriString)
If you use that how the heck can you send something to "mypage.html?view=2.0" if it escapes all strings entered?
modified on Friday, April 18, 2008 2:45 PM
|
|
|
|
|
Wow, never thought I'd see something this dumb, done by the .NET team...
I found the solution:
You have to make Two URI's and use one as the base URI, so now you have two strings (for no reason), more than one line of code, and two URI objects...
example:
Uri base = new Uri("http://www.google.com/search");
Uri final = new Uri (base, "q=WTF");
Which is sooo much easier and better than:
Uri final = new Uri ("http://www.google.com/search?q=WTF", true);
WTF! why on earth would a programmer willing change it TO this?? This belongs on http://www.thedailywtf.com not in .NET
|
|
|
|
|
Hi Im having a problem with SQL and C#.
Here is a copy of my code where the problem is occurring.
private void button1_Click(object sender, EventArgs e)<br />
{<br />
oleDbConnection1.Open();<br />
oleDbDataAdapter1.SelectCommand.CommandText = "SELECT * FROM NASDATA where account = 'test'";<br />
oleDbDataAdapter1.UpdateCommand.ExecuteNonQuery();<br />
oleDbConnection1.Close();<br />
}
I get an exception error on the ExecuteNonQuery line.
NullReferenceException was unhandled.
Object refernece not set to an instance of an object.
On the design page i have the Oledb connector and dataadapter setup, and the test connection succeeds.
Note: I had this same problem using an Access database to.
I really hope somebody can help.
Many thanks!
|
|
|
|
|
Put a breakpoint on the ExecuteNonQuery line. When the program gets there is oleDbDataAdapter1.UpdateCommand null?
|
|
|
|
|
I apologise, i realise i put the update command instead of select.
However, i get the same problem (nullreferenceexception) if i change the code to the following:
oleDbConnection1.Open();<br />
oleDbDataAdapter1.UpdateCommand.CommandText = "UPDATE NASDATA SET EMAIL = 'TESTEMAIL' WHERE ACCOUNT = 'TEST'";<br />
oleDbDataAdapter1.UpdateCommand.ExecuteNonQuery();<br />
oleDbConnection1.Close();
It breaks on the UpdateCommand.CommandText line, saying NullReferenceException was unhandled.
Object refernece not set to an instance of an object.
|
|
|
|
|
it's the same problem. oleDbDataAdapter1.UpdateCommand is not set to a valid object (meaning that it's null) but you're trying to access its members. Add this:
oleDbDataAdapter1.UpdateCommand = new OleDbCommand();
before you try to use UpdateCommand .
|
|
|
|
|
Hi there,
how can i use application A to do something from another application?
Both applications are in C#
One application keeps track of something and when needed, needs to fire an event in the other application.
I could use arguments to start an application, but in this case the other application is already running.
Any tips or examples here?
I'm not sure as how to call it,...it's a little like client server, but,...
Hoping for some info...
Jan
|
|
|
|
|
There are number of things you can do, though "keeps track of something" is rather vague.
If it's a database you could use SQLNotification so one app will be aware changes the other app has made to the database. The same can be done with files using a FileSystemWatcher.
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: There are number of things you can do
Yes there are. In this case I like the idea of putting two fingers in this guys eyes the way Moe[^] used to do. Nyak nyak nyak woop woop!
led mike
|
|
|
|
|
If the apps are running on the same machine, you can use pipes[^] or .NET remoting or WCF to communicate between the two processes.
|
|
|
|
|
You can .NET send message to the .NET handle (kind of / sort of like a pipeline), invoke (if one process spawned/grabbed the other one), and even use the use native win32 API's also...
|
|
|
|
|
Hello, i was having a problem on coding the button.. what i want to do is put the Button on the center of the form... can anybody help me please.. i used this code.. private void generateButton_Click(object sender, EventArgs e)
{
row = int.Parse(rowsBox.Text);
col = int.Parse(colBox.Text);
Button[,] landmine = new Button[row, col];
for (int _row = 0; _row < row; _row++) {
for (int _col = 0; _col < col; _col++) {
landmine[_row, _col] = new Button();
landmine[_row, _col].Width = 35;
landmine[_row, _col].Height = 35;
landmine[_row, _col].Left = 100 + _col * 35;
landmine[_row, _col].Top = 100 + _row * 35;
landmine[_row, _col].BackColor = Color.LightGray;
Controls.Add(landmine[_row, _col]);
}//end of for loop for columns...
}//end of for loop for row...
}
|
|
|
|
|
Hello,
Get the form width and height and set the button location.
Eg:
this.button1.Location = new System.Drawing.Point(form1.widht, form1.height);
Regards!
Charith
jayasshc
|
|
|
|
|
Hi,
There was a small issue with my example
use this way
this.button1.Location = new System.Drawing.Point(form1.widht/2, form1.height/2);
jayasshc
|
|
|
|
|
Try adding a panel to your form and adding the landmine controls into that panel. Then all you have to do is centre the panel controls. e.g.
<br />
private void generateButton_Click(object sender, EventArgs e)<br />
{<br />
int row = int.Parse(rowsBox.Text);<br />
int col = int.Parse(colBox.Text);<br />
<br />
Button[,] landmine = new Button[row, col];<br />
for (int _row = 0; _row < row; _row++)<br />
{<br />
for (int _col = 0; _col < col; _col++)<br />
{<br />
landmine[_row, _col] = new Button();<br />
landmine[_row, _col].Width = 35;<br />
landmine[_row, _col].Height = 35;<br />
landmine[_row, _col].Left = _col * 35;<br />
landmine[_row, _col].Top = _row * 35;<br />
landmine[_row, _col].BackColor = Color.LightGray;<br />
panel1.Controls.Add(landmine[_row, _col]);<br />
}
}
<br />
panel1.Size = new Size(row * 35, col * 35);<br />
Size parentSize = panel1.Parent.ClientSize;<br />
panel1.Location = new Point((int)(parentSize.Width / 2 - panel1.Size.Width / 2), (int)(parentSize.Height / 2 - panel1.Size.Height / 2));<br />
} <br />
You could also set the Anchor property on the panel to None to keep the controls centred while the form resizes.
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Sir, thank you so much.. it worked.. i never thought that it would just be it.. .. thank you so much again sir...
|
|
|
|
|
Good day my good fellows.
I am really struggeling with the following problem.
I am generating a Crystal Report from a data set using C#.
The report must consist of 2 pages.
Page 1) Is a letter conaining 1. Recipient Name
2. Issue
these two values are drawn from the dataset. The apear only once on the 1st page
Page 2) Is a summury of the Recipients' accounts with a specified service provider.
fields are Details, Acc No, Interest Rate, Instalment Amt, Balance.
Now, I cant seem to get the Account detail displayed on the 2nd page without the whole report being pulled out of preportions.
I tried using Groups and I tried using sub reports but they dont work.
Sub reports might work but it does'nt seem to work very well with the CrystalReports pagaged with Visual studio.
help would be appreciated.
|
|
|
|
|
Hey Guys,
i have a dataGridView control on my form with only one column of type string. Now i need to get all the strings out of it one by one... how would i do that cuz it cant foreach
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
for(int i = 0; i < dataGridView.Rows.Count; i++) {
Console.WriteLine(dataGridView.Rows[i][0]); }
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hey, thanx for the reply...
that was the logical sollution for me too, but it doesnt allow the 2nd index (the one for the column)
i tried these and they did not work
foreach (DataGridViewRow row in pollTimesDataGridView)
{
string myString = row[0];
MessageBox.Show(myString);
}
for (int i = 0; i < pollTimesDataGridView.Rows.Count; i++)
{
MessageBox.Show(pollTimesDataGridView.Rows[i][0]);
}
any ideas?
thanx justin
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi,
Here is the code for foreach
DataGridView grvCompany = new ....;
foreach (DataGridViewRow row in grvCompany.Rows)
{
//
}
Thanks!
Charith
jayasshc
|
|
|
|
|
Run code, press down arrow, up arrow, down arrow.
Invalid operatoin exception occurs.
How to fix ?
Andrus.
using System;<br />
using System.Windows.Forms;<br />
using System.ComponentModel;<br />
<br />
class Supplier {<br />
public string Id { get; set; }<br />
}<br />
<br />
class Form1 : Form {<br />
[STAThread]<br />
static void Main() {<br />
Application.Run(new Form1());<br />
}<br />
<br />
public Form1() {<br />
DataGridView grid = new DataGridView();<br />
grid.EditMode = DataGridViewEditMode.EditOnEnter;<br />
ComboBoxColumn comboBoxColumn = new ComboBoxColumn();<br />
ComboBoxCell ComboBoxCell = new ComboBoxCell();<br />
comboBoxColumn.CellTemplate = ComboBoxCell;<br />
grid.Columns.Add(comboBoxColumn);<br />
BindingList<Supplier> l = new BindingList<Supplier>();<br />
l.Add(new Supplier());<br />
grid.DataSource = l;<br />
Controls.Add(grid);<br />
}<br />
<br />
class ComboBoxColumn : DataGridViewComboBoxColumn { }<br />
<br />
class ComboBoxCell : DataGridViewComboBoxCell {<br />
public override Type EditType {<br />
get {<br />
return typeof(ComboBoxEditingControl);<br />
}<br />
}<br />
<br />
}<br />
<br />
class ComboBoxEditingControl : ComboBox, IDataGridViewEditingControl {<br />
protected int rowIndex;<br />
protected DataGridView dataGridView;<br />
protected bool valueChanged = false;<br />
<br />
protected override void OnTextChanged(EventArgs e) {<br />
base.OnTextChanged(e);<br />
NotifyDataGridViewOfValueChange();<br />
}<br />
<br />
protected virtual void NotifyDataGridViewOfValueChange() {<br />
valueChanged = true;<br />
if (dataGridView != null) {<br />
dataGridView.NotifyCurrentCellDirty(true);<br />
}<br />
}<br />
<br />
public Cursor EditingPanelCursor {<br />
get {<br />
return Cursors.IBeam;<br />
}<br />
}<br />
<br />
public DataGridView EditingControlDataGridView {<br />
get {<br />
return dataGridView;<br />
}<br />
set {<br />
dataGridView = value;<br />
}<br />
}<br />
<br />
public object EditingControlFormattedValue {<br />
set {<br />
if (value.ToString() != Text) {<br />
Text = value.ToString();<br />
NotifyDataGridViewOfValueChange();<br />
}<br />
}<br />
<br />
get {<br />
return Text;<br />
}<br />
}<br />
<br />
public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts<br />
context) {<br />
return Text;<br />
}<br />
<br />
<br />
<br />
public void PrepareEditingControlForEdit(bool selectAll) { }<br />
<br />
public bool RepositionEditingControlOnValueChange {<br />
get {<br />
return false;<br />
}<br />
}<br />
<br />
public int EditingControlRowIndex {<br />
get {<br />
return rowIndex;<br />
}<br />
<br />
set {<br />
rowIndex = value;<br />
}<br />
}<br />
<br />
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle<br />
dataGridViewCellStyle) {<br />
DropDownStyle = ComboBoxStyle.DropDown;<br />
}<br />
<br />
public bool EditingControlWantsInputKey(Keys keyData, bool<br />
dataGridViewWantsInputKey) {<br />
return !dataGridViewWantsInputKey;<br />
}<br />
<br />
public bool EditingControlValueChanged {<br />
<br />
get {<br />
return valueChanged;<br />
}<br />
set {<br />
valueChanged = value;<br />
}<br />
}<br />
}<br />
}
Andrus
|
|
|
|
|
If I was you, I'd think it would be easiest to get help if I posted the entire, actual error message, and only the little relevant piece of code. Otherwise, we have to guess where the error is coming from, and what it is, because no one is going to read through all that code to find where it is coming from.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Justin,
thank you.
Exception occurs in Application.Run() method:
System.InvalidOperationException was unhandled
Message="Operation is not valid due to the current state of the object."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at System.ComponentModel.BindingList`1.AddNewCore()
at System.ComponentModel.BindingList`1.System.ComponentModel.IBindingList.AddNew()
at System.Windows.Forms.CurrencyManager.AddNew()
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.AddNew()
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnNewRowNeeded()
at System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell& dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean canCreateNewRow, Boolean validationFailureOccurred)
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick)
at System.Windows.Forms.DataGridView.ProcessDownKeyInternal(Keys keyData, Boolean& moved)
at System.Windows.Forms.DataGridView.ProcessDownKey(Keys keyData)
at System.Windows.Forms.DataGridView.ProcessDataGridViewKey(KeyEventArgs e)
at System.Windows.Forms.DataGridView.ProcessKeyPreview(Message& m)
...
This is probably caused because DataGridView does not call RemoveItem() event when it cancels edit.
You can run this code to see it.
Andrus.
Andrus
|
|
|
|
|
I am a junior software engineer..am getting so much of doubts on sql server 2000.Tell you..please solve my issue to work with it better.
Ok the matter is ,how can i insert a lot of strings in the same time to the same field ?.
for example..I want to insert 'xp','vista','mac' and a hundreds of other names again.
So how can i add those hundreds of strings with one querry.
and it should go to one and same field
help me please...
|
|
|
|