|
I think here is problem:
nighttrain_ wrote: VALUES (,
It should be
VALUES (
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
i tried it and the same wrong result, still NULLS
|
|
|
|
|
I know this sounds really basic - but have you tried running this in debug mode and outputting the values of these objects:
System.Diagnostics.Debug.WriteLine(tbPrice.Text);
System.Diagnostics.Debug.WriteLine(tbNumberOfPeople.Text);
System.Diagnostics.Debug.WriteLine(tbChildren.Text);
System.Diagnostics.Debug.WriteLine(tbStartDate.Text);
System.Diagnostics.Debug.WriteLine(tbEndDate.Text);
Just to make sure that they contain what you expect them to contain...
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
Mayby it's lame but how can I use this debug mode, i create a button and paste Yours:
System.Diagnostics.Debug.WriteLine(tbPrice.Text);
System.Diagnostics.Debug.WriteLine(tbNumberOfPeople.Text);
System.Diagnostics.Debug.WriteLine(tbChildren.Text);
System.Diagnostics.Debug.WriteLine(tbStartDate.Text);
System.Diagnostics.Debug.WriteLine(tbEndDate.Text);
mayby it's lame question but how should i do that?
|
|
|
|
|
I don't have the visual studio IDE at work but you will need do something like select debug from a menu at the top and F5 to start debugging - you will also need to open what I believe is called the "output" window.
Best thing is to google how to debug in Visual studio - wish I could be of more help...
Being able to use the debug facilities is a must have skill for C# clickety[^]
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
I don't know, a textbox.Text should never be NULL, but there's an awful lot of bad technique there.
0) Use parameters for all the values
1) Don't use strings for numeric and date values
2) Try using NumericUpDowns and DateTimePickers
|
|
|
|
|
i start debug and open Output Window but it's strange what i saw:
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'D:\_Programowanie\_Moje projekty\OKIENKOWE\HMS\HMS\hms\branches\hms.application\bin\Debug\hms.application.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 'vshost.NotifyLoad' (0x1500) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x954) has exited with code 0 (0x0).
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'D:\_Programowanie\_Moje projekty\OKIENKOWE\HMS\HMS\hms\branches\hms.application\bin\Debug\hms.application.exe', Symbols loaded.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\MySql.Data\5.2.7.0__c5687fc88969c44d\MySql.Data.dll'
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 'vshost.RunParkingWindow' (0x10b8) has exited with code 0 (0x0).
The thread '<No Name>' (0xba8) has exited with code 0 (0x0).
The program '[5072] hms.application.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[5072] hms.application.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
Anyone could look at that and write something about it ?
|
|
|
|
|
Firstly, if at all possible, you should use parameterised queries, and if not, you must escape the contents of those text boxes before creating the query string. At the moment, if those are free text boxes, there is a huge SQL injection hole in this code.
Secondly, you should be using a DateTimePicker or similar for the dates, and using myDateTimePicker.Value.ToString("yyyy-MM-dd") to get them in database format. Edit from the subthread below: If you are using parameterised queries, you should (of course) pass the date as a DateTime. The string formatting is only if you are building a query string. Ideally you should use a numeric text box type as well but inexplicably that doesn't exist in the standard framework.
Thirdly, I suspect the immediate cause of the problem is that the dates are not in a valid format. See what the string you are actually creating really looks like, and compare it to a static query that works.
modified on Thursday, July 21, 2011 1:02 PM
|
|
|
|
|
BobJanova wrote: using myDateTimePicker.Value.ToString("yyyy-MM-dd") to get them in database
format
No, don't do that; just put the DateTime in a parameter.
|
|
|
|
|
I did start my answer with 'if at all possible, use a parameterised query'. Yes, that is better if it's possible (and it almost always is).
|
|
|
|
|
Yes, but as a DateTime, not as a String.
|
|
|
|
|
I meant that formatter to only be used in the case that the OP couldn't use parameterised queries, so he was building up the query string (where obviously everything must be a string). But you are right, I didn't make that clear, so I'll go and edit my initial message. Thanks!
|
|
|
|
|
Remove the single quotes for text fields if using alphabets in text. And # symbol to insert date.
|
|
|
|
|
i tried to use a new two parameters:
m_insert_cmd2.Parameters.Add("@DateStart", MySqlDbType.DateTime).Value = this.dateTimePicker1.Text;
m_insert_cmd2.Parameters.Add("@DateEnd", MySqlDbType.DateTime).Value = this.dateTimePicker2.Text;
and tried like this:
m_insert_cmd2.Parameters.Add("@DateStart", MySqlDbType.DateTime).Value = this.dateTimePicker1.Text.ToString();
m_insert_cmd2.Parameters.Add("@DateEnd", MySqlDbType.DateTime).Value = this.dateTimePicker2.Text.ToString();
the same problem is communicat:
String was not recognized as a valid DateTime.
my full query look like:
m_insert_cmd2 = new MySqlCommand("INSERT INTO tb_rezerwacja (kwota, ilosc_osob, w_tym_ilosc_dzieci, data_od, data_do, FK_pokoj_id, FK_zamowienie_id) VALUES (' 345', '3', '3', @DateStart, @DateEnd, @pokoj_id, @zamowienie_id)", m_conn);
on form i add 2 dateTimepickers like u see and in MySQL database the date fields are in Date format...
modified on Wednesday, July 20, 2011 3:00 PM
|
|
|
|
|
|
Hello Experts,
If i have a string "abc". then how can i get the shown output
a
b
c
ab
bc
ac
abc
In this output i do't need of ba or cab or cba.
Thanks
If you can think then I Can.
|
|
|
|
|
Is this, what you are looking for?
string value="abc";
string result=string.Empty;
for(int i=0;i<=value.Length-1;i++)
{
result+=value[i].ToString()+"\n";
}
for(int i=0;i<=value.Length-1;i++)
{
if(i<value.Length-1)
{
result+=value[i].ToString()+value[i+1].ToString()+"\n";
}
else
{
result+=value[0].ToString()+value[value.Length-1].ToString()+"\n"+value;
}
}
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
The Length of value is not fixed for 3
it can be increase and the result will be change according to input.
then how can i do that.
If you can think then I Can.
|
|
|
|
|
Length of string is dynamic too on my example.
Did you try my code to see result?
Which is result for you if the string is "abcd"
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
the result by program is :
a
b
c
d
ab
bc
cd
abcd
But Required result is :
a
b
c
d
ab
bc
cd
da
bd
abc
bcd
dab
....
abcd
..etc
If you can think then I Can.
|
|
|
|
|
Backtracking . You can search google to more detail .
I can it useful for you . Thanks !!
|
|
|
|
|
Homework question?
Should the output contain ACB? or strictly ordered?
|
|
|
|
|
A double iteration over the input string with position and substring length :
string str = "anystring";
for (int x = 1; x <= str.Length; x++)
{
for (int y = 0; y <= str.Length - x; y++)
{
Console.WriteLine(str.Substring(y, x));
}
}
Cheers
|
|
|
|
|
Hello Estys,
Thanks for your solution.But it is missing values.
Input : ABC
Output :
A
B
C
AB
BC
CA // Missing Value
SO pls provide the solution for that.
If you can think then I Can.
|
|
|
|
|
I didn't see the "CA" value, ouch!
Can you give an example of the expected output if the input is "ABCD"?
Or perhaps describe the situation in words? I suspect you're going to need some recursive algorithm.
Cheers
|
|
|
|