|
Deian wrote: sqlCmd.Parameters.AddWithValue("@id", nCustomerID.ToString());
Don't all ToString() on nCustomerID
Also, it is good practice to put the calls to Dispose in a finally block so that they get called even if an exception is thrown. At the moment, the objects won't be disposed when the exception is thrown.
Other than that I don't really see much wrong with the code.
|
|
|
|
|
Yes I will dispose objects in finally block, this is just a test function. Too sad nobody could reproduce my parameter problem.
|
|
|
|
|
Sometimes when that happens to me and I just simply cannot see what is wrong with a method then I tear down the method so it has nothing in it, go and get something to drink (anything to get away from the code for 5 to 10 minutes) come back and start from scratch on that method. Often that helps. And often the code is also better quality as a result too.
|
|
|
|
|
Well, I did that last night
I've traced the problem to my working stations, since sql profiler shows that query arrives with "... WHERE col=@param". IDE is not throwing an exception that parameter is missing, actually it is there. What I will do (in order to get going) is to construct dynamic queries and pass them directly, untill I find a solution.
Thank you for the reply!
|
|
|
|
|
Hello all,
I am having an annoying little problem with accessing an underlying row in a datatable which is being displayed in a datagridview.
I need to get hold of the ID column in the DataSource, however it is one of the columns I am not displaying to the user in the DataGridView. I can then fire a stored procedure to delete the correct row from the SQL database.
How do i access the row which is currently selected in the DataSource? I know about SelectedRows[] but it doesnt contain my ID column.
Thanks in advance...
modified on Tuesday, April 22, 2008 10:18 AM
|
|
|
|
|
when you select row from datagridview then save ID value in one label,use labels value to delete your data based on last selected ID on datagridview.
I Love T-SQL
|
|
|
|
|
Could do but thats a big hack i think there has to be a nicer way
|
|
|
|
|
GOTCHA!!!
DataRow bishyBashy = ((DataRowView)(this.dataGridViewExistingSecurityLevels.SelectedRows[0].DataBoundItem)).Row;
|
|
|
|
|
Hi, I need your help to clarify the following.I try to run a method with the parameters on own thread. But I get the error.
public class MyQueue
{
Queue myQueue = new Queue();
public void Enqueue(PacketHeader p, byte[] s)
{
Data data = new Data(p, s);
myQueue.Enqueue(data);
}
}
m_myQueue = new MyQueue();
Thread thread = new Thread(new ThreadStart(m_myQueue.Enqueue(????)));
thread.Start();
Thanks in advanced
Mehran
|
|
|
|
|
Wrong threading type, look at the threading articles for .NET for the correct method (note this is a pun!) to do this
Well you could do this with properties, but if you just want to run a method this follow my above statement
|
|
|
|
|
|
NP, just be careful and be sure to call EndInvoke on your ISyncResult object, that is if the method is should to finish even if the caller would have ended first.
|
|
|
|
|
|
Google broken?
only two letters away from being an asset
|
|
|
|
|
If you don't want to google...
gogle[^]
gooogle[^]
googel[^]
ogogle[^]
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
An event is basically a list of delegates.
One part of your code (or different parts of the code) can subscribe to an event by adding one or more event handlers to the event. Another part of your code can invoke the event, which will call all the event handlers registered in the event.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
There goes my week! I always thought an event was a moment in time, that is remembered due to some action which took place guess I was wrong.
|
|
|
|
|
SpacixOne wrote: There goes my week! I always thought an event was a moment in time
You're wrong: it's a point in the four dimensional time-space.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi People,
First of: Im new in the world of C#.
I'm making a application that needs to connect to an access database.
Some gridviews will be filled with data that matches some criteria (eg. all invoicelines from one specific invoice), but there are also objects (eg. comboboxes) that will be filled without criteria.
I read allot bout dataset / typed dataset... I don't understand.
I googled but there is too much info which I don't understand.
I think I can savely say that most people prefer typed datasets?
What is my best option and where the h*ll do I start?
Besides: The location of my backend (access.mdb) needs to be variable.
Hope someone can get me on my way.
Thanks!!
Richard
|
|
|
|
|
A very broad and vague question, if there is one in your post. What are you trying to ask?
only two letters away from being an asset
|
|
|
|
|
Applogies! Youre right.
My question(s) is / are: what can I use best for my purpose? typed or non-typed datasets?
Is there any good tutorial regarding typed datasets?
Thanks,
Richard
|
|
|
|
|
RitchieRich wrote: what can I use best for my purpose?
The best method for your project is whats best. One technique may work well in one circumstance, but not in another.
Typed Datasets are of course just DataSets, so either will work, it all depends on what you want to do with it. If you are just binding the controls, then there isn't much need for a typed dataset. However, if you are manipulating the the dataset and want strong names and type safety, then by all means use a typed dataset. Do you even need a dataset, will a datatable server the purpose?
only two letters away from being an asset
|
|
|
|
|
Well.. i need to manipulate data in e.g. a gridview.
Preferbly I just have a ' direct' connection to the database when I make some changes in the gridview the changes are directly commited to the database. (that was in access the case)
As you can probably tell, im a newbie on this topic.
Do you have any good suggestions where I should begin with C# ??
Thanks
Richard
|
|
|
|
|
<code>Public Sub MassReplace()
With Application.FileSearch
.LookIn = "C:\AWCzx10" ' where to search
.SearchSubFolders = True ' search the subfolders
.FileName = "*.TXT" ' file pattern to match
'NOTE: I got this code from a friend, I do not know who originally wrote it so all credits go to the owner.
' I need to be able to batch edit the documents TXT files
If .Execute() > 0 Then
' to display how many files this macro will access,
' uncomment the next line of code
' MsgBox "Found " & .FoundFiles.Count & " file(s)."
' for each file you find, run this loop
For i = 1 To .FoundFiles.Count
' open the file based on its index position
Documents.Open FileName:=.FoundFiles(i)
'there are a bout 20 different items being swapped or removed here
'so I just listed a couple to keep it simple
'***************************************HERE WE GO *******
'ActiveWindow.ActivePane.View.Zoom.Percentage = 200
' Selection.Find.ClearFormatting
' Selection.Find.Replacement.ClearFormatting
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "Mz01"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "M2z07"
.Replacement.Text = "M5zz1 trr455 sd65y"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
'the list goes on and on
'************************************END OF SWAPPING FOR ALL FILES****
' save and close the current document
ActiveDocument.Close wdSaveChanges
Next i
Else
' if the system cannot find any files
' with the .doc extension
MsgBox "No files found."
End If
End With
End Sub
</code>
I need to load the code on a simple form with a button that executes the code, plain and simple with no input from the user.
I loaded the reference to the XPias, but I can not successfully transfer the code over.
Thank You in advance!
|
|
|
|
|
Steps to converting VBA to c#
1) Convert into VB.NET and run it though a VB.NET to C# converter and edit the crappy converted code to good code
2) ???
3) Profit!
|
|
|
|