|
Username or password might be reserved words, depending on what connection you use. Put brackets around them: [username], [password]
---
b { font-weight: normal; }
|
|
|
|
|
The problem was with Password as a reserved word. once put it brackets around it- solved.
cheers!
Ronen
|
|
|
|
|
You need to enclose your values in single quotes:
... "VALUES ('" + username.UserName+ "','" + username.Password + "')";
note the extra single quotes I have added.
A better way to do this would be to use parameters and a stored procedure (querydef in access lingo), then you wouldn't have to worry with things like the single quotes (which will need to be doubled up if they are part of a name - O'Neill - becomes O''Neill - in order to work). If you use a strored procedure with parameters, you won't have to worry about escaping the embedded single quote.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
Hi, how can I edit an windows control property with other threading tha the current works in the form?
I make a threat to do some tasks, and I want to show to the user the progress in a progress bar and subtask it is doing in label.
I try but throw me an exception because the threadin to edit controls property is other than the one is doing my custom tasks.
than you!
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
You can't access a control directly from a thread different than the one that created the control you need to use Invoke or BeginInvoke to do this. See this article[^] for more details.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
Hi..
I have a datagrid and an EditCommand
Now, when I click the UpdateCommand- link button...
private void dgProjects_ItemUpdate(object sender,DataGridCommandEventArgs e )
{
string ProjectId = e.Item.Cells[0].Text
....
}
It should return me the first column value in the clicked row???
But its not...
Is something wrong.. or some other way...???
Thanks
|
|
|
|
|
The answer is a little more complicated than it should be....Or at least I thought it should be.
The following code is meant to take the value of the cell (that the user has selected and changed)and write this value into the database. It then refreshes the DataGrid to show the new value.
The hardest part to understand is that you have to create a DataGridTableStyle object to do this. The reason for creating this object is that the class provides the necessary methods and properties that you need to access.
<br />
private void updateButton_Click(object sender, System.EventArgs e)<br />
{<br />
DataGridTableStyle ts1 = new DataGridTableStyle();<br />
<br />
DataGridCell myCell;<br />
myCell = UserdataGrid.CurrentCell;<br />
<br />
ts1.MappingName = "SessionTable";<br />
<br />
UserdataGrid.TableStyles.Add(ts1);<br />
<br />
string infoStr = null;<br />
int j = 0;<br />
<br />
foreach(DataGridTableStyle gridStyle in UserdataGrid.TableStyles)<br />
{<br />
<br />
foreach(DataGridColumnStyle colStyle in gridStyle.GridColumnStyles)<br />
{<br />
if (j == myCell.ColumnNumber)<br />
{<br />
infoStr = colStyle.MappingName;<br />
}<br />
j++;<br />
}<br />
}<br />
<br />
int i = UserdataGrid.CurrentRowIndex;<br />
<br />
String userId = UserdataGrid[i, 7].ToString();<br />
<br />
sql.UpdateRecord("SessionTable", infoStr, "UserId", userId, UserdataGrid[myCell].ToString());<br />
<br />
FillData();<br />
UserdataGrid.SetDataBinding(dataSet, "SessionTable");<br />
UserdataGrid.Refresh();<br />
}<br />
<br />
Whoooo!!! It sure seems like alot of work just to get a value, change it and then display the changes. But there are some positive things to note:
1) This is the entire implementation(minus the sql statements for the database and the implementation of FillData())
2) I did not have to use EditCommand
3) Though not the most elegent solution, it works!
Well, I hope this helps. I know what it's like to wonder why something isn't working when it looks like it should. Sometimes we need to look outside of the "logical box" to make it work.............
Have a good one,
Snowblind37 aliasing as CodeBlind37 these days.
|
|
|
|
|
How come I cant define the List type using the statement:
List<int> intList = new List<int>();
it seems it does not recognize the List definition.
Thank you.
|
|
|
|
|
Did you wrote a using directive for the correct namespace, so the use of types in that namespace is allowed without having to specify the namespace.?
www.troschuetz.de
|
|
|
|
|
The only directive that I think I need is System.Collections;
And that is what I have.
Do I need some other directives to use List
Thank you
|
|
|
|
|
The System.Collections namespace doesn't contain a List type. There are ArrayList or SortedList type and IList interface.
www.troschuetz.de
|
|
|
|
|
There is no List definition in C#. I suggest you go to http://msdn.microsoft.com/ . There you will be able to find the definitions of all the classes available. They are mostly the same for C# and VB, etc. Actual class names will differ from Java but the functionality will be more or less the same.
CodeBlind37
|
|
|
|
|
Hi,
I've got a program that reads field names and values from a database table and searches Xml documents for them. I find them in the Xml file using XPath XPathNavigator and the XPathNodeIterator objects. However, I can't find a method that replaces a node value once I find it, I've looked through other classes such as XmlWrite, XmlNode, etc but I can't find anything suitable.
There must be something in .NET that repalces a node(tag) value in Xml according to the node structure??
|
|
|
|
|
Hello,
I'm trying to close a MDI child (by calling this.Close() ) is trying in the Validated event handler for one of its controls, but it refuses to close.
I've checked the OnClosing handler, and when called, e.Cancel is always true. I tried setting it to false , but then I get a NullReferenceException (not in my code, my debugger just pops up pointing at the last line of code in my Main ).
I could just hide it, but I would like it to be closed later, so it's not taking up memory unnecessarily.
It seems that when I try to close it, it's in some process that has to finish, and that's the reason of the NullReferenceException .
Could anyone shed some light?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
A few things come to mind........
-What other signal flow might be trying to run? I would find this out before anything. Do you have an infinate loop going on somewhere? A reference to a method that is waiting for information?
- The NullReferenceException is likely because it hasn't reached the OnClosing handler
- Does the code even reach your this.Close(). Try printing out an "I'm here" before the Close and see if it is even getting that far
- Not a bad idea to print out statements all the way through the flow and see where it crashes
Hope that helps
CodeBlind37
|
|
|
|
|
I've solved it. I already had a timer firing every 1/4 of a second, so I just set a flag mustClose to true, and in the timer the form closes itself. And it works fine.
But I still have the doubt on why it didn't work.
Snowblind37 wrote:
What other signal flow might be trying to run? I would find this out before anything. Do you have an infinate loop going on somewhere? A reference to a method that is waiting for information?
No. Nothing else. Basically on the Validated event, if it finds a duplicate asks on how to proceed (in a modal form) and if user chooses to work on the duplicate, Close() is called before returning from the event handler.
Snowblind37 wrote:
The NullReferenceException is likely because it hasn't reached the OnClosing handler
It's after the OnClosing. I've verified it in the debugger, and the exception only happens if I set e.Cancel to false in the OnClosing handler (which misteriously is set to true .)
Snowblind37 wrote:
Does the code even reach your this.Close().
Yes, and from there it goes to the OnClosing handler, with e.Cancel set to true (it's not a base class where a derived class could set it before.)
Snowblind37 wrote:
Not a bad idea to print out statements all the way through the flow and see where it crashes
I've stepped through all my code in the debugger. The crash is only when I try to set e.Cancel = false in the OnClosing handler, and it occurs after my handler returns, somewhere in the middle of the framework code.
When I have some time, I'll try to reproduce it in a simpler program.
Thanks for your comments!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Excellent!!! I'm glad to hear that you got it going.
As to why this may have been happening? Your timer was probably using most of the processor time as well as being the focus of your program running time. Setting that flag was a way of making your program do something else.
I suggest that you create a new thread for your timer and make sure it sleeps, then awakes at certain intervals.
Code On and Good Luck!!!
CodeBlind
|
|
|
|
|
I would like to know what is the best way to onnect to connect to a database in general which provides you with full functionality & fast access?
Best Regards,
Jassim Rahma
|
|
|
|
|
You have a number of options based largely on performence and security. You could consider using a DataAdaptor (OleDbDataAdapter/SqlDataAdaptor with a DataSet/DataTable from System.Data.OleDb and System.Data.SqlClient respectivly) with a command builder for retrieving and updataing data. DataAdaptors can be useful when you are working with data from multiple data sources (dbs, tables, etc).
Alternativly, the DataReader can be used if your dealing with large volumes of data (e.g so much you exceed a single cache) and want to streamline and optmise data access to your source.
A starting point anyway...
|
|
|
|
|
I have a simple setup outlined below, but when I try to run it I get this message: Object reference not set to an instance of an object.
Why do I get this message, if I declare the dataset in the declaration
section of the class ProjectSetup
Here is the setup:
public class ProjectSetup : System.Windows.Forms.Form {
.
.
.
private DataSet dataset = new DataSet();
// Constructor
public ProjectSetup ()
{
.
.
PopulateLocationComboBox();
}
private void PopulateLocationComboBox ()
{
// Populate ComboBox
foreach (DataRow row in this.dataset.Tables["Location"].Rows)
{
string item = row["Name"].ToString();
this.comboBoxLocation.Items.Add(item);
} // End of FOREACH statement
}
private void ProjectSetup_Load(object sender, System.EventArgs e)
{
.
.
adapterLocation.Fill(dataset, "Location");
}
}
Error message occurs in PopulateLocationComboBox () in foreach statement
when I am trying to access the dataset.
Thank you.
|
|
|
|
|
It throws that exception probably because you don't have a table in the dataset called Location . You might want to check for it before you try to get the Rows collection out of it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
ProjectSetup_Load is called after the constructor, so there is no table Location in your dataset and the exception is thrown.
www.troschuetz.de
|
|
|
|
|
Thank you, I already figured that out with print statements.
I really apreciate the help.
|
|
|
|
|
Help is what we are there for
And it's good to here that you didn't only wait for an answer, but figured out the problem yourself.
www.troschuetz.de
|
|
|
|
|
Hi guys, first time posting.
I have a project with a windows form client, and a class library. in the main form I instantiate the gallery class like this:
Gallery cgsGal = new Gallery();
ok, so that's all find and dandy.
now, i have another form which sells an art piece from the gallery. if i instantiate another Gallery instance on the second form it doesn't find my collection to iterate through to find the Art Piece to sell.
How do I use the instance of gallery from the the first form, on the second form?
I feel I should know this. I can't find anything in my book (Beginning Visual C#, Karli Watson Et Al) about it. If someone could lend a hand (or a brain) I'd be very thankful.
Bryan.
|
|
|
|