|
|
|
So? It's the same general idea.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Very Easy.
Dim con as SQlConnection(ConnectionString)
con.open()
dim cmd as new sqlcommand("StoredProcedureName",cn)
cmd.CommandType=Commandtype.StoredProcedure
'if Stored procedure return rows
dim dr as sqldatareader=cmd.ExecuteReader
'if Stored procedure do not return rows then
cmd.executenonquery
'if stored procure has parameters
cmd.parameters.add(new sqlparameter("@parameterName1",value))
cmd.parameters.add(new sqlparameter("@parameterName2",value))
..........................
'then excute it by Executereader or executenonquery
Hope This will solve your problem
|
|
|
|
|
Thank you for you help me,
I'm run this but return this msg:
Syntax error converting datetime from character string.
I'have this format in my SQL data base field
2005-06-21 00:00:00.000
I'have in my form two datetimepicker
cmdOrders.Parameters.Add(New SqlParameter("@StartDate", Dtpicker1.Value))
cmdOrders.Parameters.Add(New SqlParameter("@EndDate", Dtpicker2.Value))
how format the date.
thank you.
|
|
|
|
|
There is a lot of documentation and examples already available covering what you are asking for. Specifically what is it that you have problems with?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I'have this.
Dim sConnectionString As String = _
"server=rs500001\rptsrv;uid=user;pwd=pass;database=rpt"
Dim cnNorthwind As New SqlConnection(sConnectionString)
Dim cmdOrders As New SqlCommand("sp_Sales", cnNorthwind)
cmdOrders.CommandType = CommandType.StoredProcedure
cmdOrders.Parameters.Add(New SqlParameter("@StartDate", SqlDbType.DateTime))
cmdOrders.Parameters"@StartDate").Value = "2008-01-01"
cmdOrders.Parameters.Add(New SqlParameter("@EndDate", SqlDbType.DateTime))
cmdOrders.Parameters("@EndDate").Value = "2008-0-10"
I'm using SQL 2000 and VB.NET 2008, but this not work, I'm want run my stored procedure, the name for this is "sp_sales".
thank you
|
|
|
|
|
reynaldosp wrote: but this not work
That's not a useful description. What happens? Does it compile? Do you get an error message? What do you expect it to do, what does it do, and how does that differ from what you expect?
reynaldosp wrote: cmdOrders.Parameters"@StartDate").Value = "2008-01-01"
You are missing a starting parenthesis after cmdOrders.Parameters.
As the data type for the parameter is DateTime, you should assign it a DateTime value, not a string.
The Add method returns a reference to the parameter, so you don't have to access it by name. Also, it has an overload that creates the parameter for you.
cmdOrders.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = new DateTime(2008, 1, 1)
reynaldosp wrote: cmdOrders.Parameters("@EndDate").Value = "2008-0-10"
That's not a valid date. I suppose you meant "2008-01-10"?
cmdOrders.Parameters.Add("@EndDate", SqlDbType.DateTime).Value = new DateTime(2008, 1, 10)
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I hope they were typos in the message posted and not the code he was trying to compile.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You never know... The variable name cnNorthwind is clearly from code taken directly from an example using the example database Northwind...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hey guys currently i have this setup.
1. Enter say "123" in textbox1.text
2. click button will search datarow in datagrid1
3. copy datarow and append it to datagrid2
4. will delete the line it copied from
for the first click it will work but the 2nd one it prompts "cannot access delete row" when what i type in textbox1.text is "345" totally different
Dim dr As DataRow, drNew As DataRow<br />
Dim dt As DataTable = objDataSet.Tables(0)<br />
<br />
For Each dr In dt.Rows<br />
For i As Integer = 0 To dt.Columns.Count - 1<br />
If dr(i).ToString = TextBox1.Text Then<br />
drNew = dt2.NewRow<br />
drNew(0) = dr(0)<br />
drNew(1) = dr(1)<br />
drNew(2) = dr(2)<br />
<br />
dt2.Rows.Add(drNew)<br />
drNew = Nothing<br />
dr.Delete()<br />
Exit For<br />
End If<br />
Next<br />
Next<br />
DataGrid2.DataSource = dt2<br />
End Sub
|
|
|
|
|
I didn't go through the code, however a couple of points when managing datarows. After changing a row(s) do Table.AcceptChanges this resets the rowstate back to current. This causes post delete processes to fail.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have seen in various custom controls that you purchase where after you drag and drop the control onto a form, a small popup screen appears where you can modify the various properties of that control by choosing items on that popup screen such as check boxes or choosing items from dropdown lists, etc.. Sort of like a wizard. Can someone show me with code how I can create such a popup screen like this where I can modify the properties of cutom control? Or give me a link where I can see an example how this is done in VB?
|
|
|
|
|
One of my articles can help you with that: Targeting Design-Time Events of UserControls[^]
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
This looks like everything I am looking for except that it is C# and I don't know c#. Do you have a version in VB?
|
|
|
|
|
The only thing different is the syntax; take away all the semicolons the braces {} and rename some of the keywords and it is VB. Basically, you can use this article as a reference for what namespaces/classes/principles you will need in your solutions (as all of the classes/namespaces are discussed in the article).
I will not convert the program to VB, frankly because I do not have the time at present, but if you have specific questions in understanding the contents of the article then you can post questions in that article forum and I will be glad to answer them. If you have a few snippetts of code that you don't undestand then I may convert those few snippetts to VB.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
I have never used drag and drop before, and i really have no idea how to do it. I am aware that all controls have an "AllowDrop" property, but i'm not really sure what that means. I also know all controls have drag-drop events, and i am unsure how to use them as well. I could really use some guidance on getting started in this. Let's just say, as an example, if i had a picture box, and when an image file is dragged onto it from explorer, i would want it to display it. Explain how to do something simple like that, and i should be able to figure out the rest. Thanks for any help.
if (your.Life != lifestyles.Programming) { me.Hate(your.Life) = true; }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
There is an excelent article by Marc Clifton that I think would be of great help to you:
Article[^]
|
|
|
|
|
How can you dynamically load values in an enum statement rather than hard code them line by line as seen in the below example code. I want to be able to load an enum statement from data I query from a database.
Typical hard coded enum
Public Enum compas_dir
North = 0
South = 1
East = 2
West = 3
End Enum
|
|
|
|
|
I think Enums have to be set at compile time. If I am right, you might want to try a different data structure, such as a collection[^], that you can manipulate at run-time. If I'm not, perhaps someone will let me know.
|
|
|
|
|
Apparently, you, Chas or someone didn't like this answer and 1-voted it. However, in its essentials, it is correct. You cannot change the values of an Enum after the application has been compiled. If you could, it would defeat the purpose of Enums.
A dictionary-type object would be a good choice for storing the kind of pair values you're probably thinking about. I'd use a hash-table, but I've been told I overuse 'em.
Jon
Smith & Wesson: The original point and click interface
|
|
|
|
|
Thanks for confirming that for me, Oakman. I'll assume they 1-voted it because it wasn't the answer they were looking for, and not because it was a bad answer, even though I really don't care.
|
|
|
|
|
If memory serves me correctly, which it does with declining ability, enums are compiled to classes extending .. suprisingly .. system.Enum. The enum members become static fields.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
I am trying to use a C# example of a usercontrol to write a VB.Net usercontrol with some simular features. My first step was to convert a C# control to VB.Net. I love this example (a newly written wizard control) and am trying to design a multi-pane control based using this control as an example of the right way to do things. However... I am not understanding the following code...
public delegate void ItemChangingHandler(int index, GenericChangeEventArgs<t> e);
public event ItemChangingHandler Changing;
protected override void OnSet(int index, object oldValue, object newValue)
{
GenericChangeEventArgs<T> e = new GenericChangeEventArgs<T>((T)oldValue, (T)newValue);
if (Changing != null)
{
Changing(index, e);
if (e.Cancel)
{
return;
}
}
base.OnSet(index, oldValue, newValue);
}
What does If (Changing != null) really do. If I translate this to VB.Net I get
Protected Overloads Overrides Sub OnSet(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
Dim e As New GenericChangeEventArgs(Of T)(DirectCast(oldValue, T), DirectCast(newValue, T))
If Changing IsNot Nothing Then
RaiseEvent Changing(index, e)
If e.Cancel Then Exit Sub
End If
MyBase.OnSet(index, oldValue, newValue)
End Sub ' (ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
Where the line "If Changing IsNot Nothing Then" generates a compiler error...
Error 1 'Public Event Changing(index As Integer, e As GenericChangeEventArgs(Of T))' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\My Projects\VB.Net\etc\ezWizard\ezWizard\Collection\GenericCollection.vb 347 10 ezWizard
I would greatly appriciate any help anyone could give me. Anyone understand C# and VB.Net?
Keith Alan Yerian
Keith Alan Yerian
|
|
|
|
|
1. You don't need to do this sort of check for VB. VB does this behind the scenes when you use RaiseEvent.
2. If you really need it, then "If ChangingEvent IsNot Nothing" works. Note the 'Event' tagged on the end of the event name. This refers to a private hidden variable that VB creates for your events.
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB & C# to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
|
|
|
|