|
0) (Unrelated to the error) There is no need to specify the datatypes for the parameters; they will be set when you set the value.
1) If you don't set the Value, or if the value is NULL, set the Value to DBNull.Value
2) You may need to set the Direction of the parameters.
3) = edtPicker; and = udtPicker; -- Don't those need a .Value ?
3) DateTime edtPicker = Convert.ToDateTime(EnterdateDateTimePicker.Value); -- you don't need to convert; just cast
DateTime edtPicker = (DateTime) EnterdateDateTimePicker.Value;
4) The procedure returns a DataTable, are you expecting it to set your parameters?
Otherwise, it seems OK.
modified 21-Oct-14 16:09pm.
|
|
|
|
|
I am not clear if I need params or not, new to this. To start, I have a very simply search, display winform. Select a radio button, (ServedBy, CaseDocNumber, SenderAddress), hit Search, and storedProc populates fields(EnterDate, EnterTime,EnterBy,CaseTypeID, MethodTypID,UpdateDate,UpdateBy) in a datarepeater in same form. Do I just bind the controls to a datasource? I figure I need to do a sql conn first, then add params. The @Fields in the storedProc throws me off thinking I need to use that. Sorry if its confusing.
|
|
|
|
|
You need the @Field and @Search parameters, and you need to set their Values, but you don't need the others. Try using AddWithValue.
And you have two parameters named @Field.
modified 21-Oct-14 16:18pm.
|
|
|
|
|
cmd.Parameters.AddWithValue("@Field", ServedBy);
cmd.Parameters.AddWithValue("@Field", CaseDocNumber);
cmd.Parameters.AddWithValue("@Field", SenderAddress);
cmd.Parameters.AddWithValue("@Field", Claim);
cmd.Parameters.AddWithValue("@Search", ID);
cmd.Parameters.AddWithValue("@Search", EnterDate);
cmd.Parameters.AddWithValue("@Search", EnterTime);
cmd.Parameters.AddWithValue("@Search", EnterBy);
cmd.Parameters.AddWithValue("@Search", CaseTypeID);
cmd.Parameters.AddWithValue("@Search", MethodTypeID);
cmd.Parameters.AddWithValue("@Search", UpdateDate);
cmd.Parameters.AddWithValue("@Search", UpdateBy);
cmd.Parameters.AddWithValue("@Search", CaseDocNumber);
cmd.Parameters.AddWithValue("@Search", SenderAddress);
//My problem is I dont know how to use @Field and @Search with diff. values like above. If a search is done with any of the @Fields, I need to return the values of @Search. Sorry I'm dumb.
|
|
|
|
|
You can't have multiple parameters with the same name.
The procedure you showed requires @Field and @Search and it handles the rest.
|
|
|
|
|
hi
i am use 4 multicolumncombi in my form in first navigatorbinding is correct but when one record insert in database my moveprevious and next previous is not show correct tytle in multicolumncombobox and
when close program and run program again bindingnavigator is correct but when save again not show tytle correct
my source code:
[php]
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{
moshtarakinhoghoghiBindingSource.AddNew();
if (phonebookDataSet.moshtarakin_hoghoghi.Compute("max(SysCode)+1", null).ToString() != null)
editBox1.Text = phonebookDataSet.moshtarakin_hoghoghi.Compute("max(SysCode)+1", null).ToString();
else
editBox1.Text = 1.ToString();
editBox3.Text = "";
editBox2.Text = "";
editBox4.Text = "";
multiColumnCombo1.Text = "";
multiColumnCombo2.Text = "";
multiColumnCombo3.Text = "";
multiColumnCombo4.Text = "";
uiComboBox1.Text = "";
}
[/php]
[php]
private void multiColumnCombo1_TextChanged(object sender, EventArgs e)
{
if (multiColumnCombo1.Text != "")
stateCityBindingSource.Filter = "State_Id='" + Convert.ToInt32(multiColumnCombo1.Value.ToString()) + "'";
}
private void multiColumnCombo3_TextChanged(object sender, EventArgs e)
{
if (multiColumnCombo3.Text != "")
activityBindingSource.Filter = "code_groh='" + Convert.ToInt32(multiColumnCombo3.Value.ToString()) + "'";
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
try
{
moshtarakinhoghoghiBindingSource.EndEdit();
moshtarakin_hoghoghiTableAdapter.Update(this.phonebookDataSet.moshtarakin_hoghoghi);
}
catch
{
}
}
[/php]
. please help me .
best regards
modified 22-Oct-14 3:51am.
|
|
|
|
|
my problem resolved
my code:
[php]
private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'phonebookDataSet.moshtarakin_hoghoghi' table. You can move, or remove it, as needed.
this.moshtarakin_hoghoghiTableAdapter.Fill(this.phonebookDataSet.moshtarakin_hoghoghi);
SqlConnection ConSub = new SqlConnection("Data Source=.;Initial Catalog=phonebook;Integrated Security=True");
ConSub.Open();
SqlDataAdapter Adapter = new SqlDataAdapter("Select * from State", ConSub);
DataTable State = new DataTable();
Adapter.Fill(State);
multiColumnCombo1.DataSource = State;
Adapter.SelectCommand.Connection = ConSub;
Adapter.SelectCommand.CommandText = "Select * from StateCity where State_Id='" + Convert.ToInt32(multiColumnCombo1.Value.ToString()) + "'";
DataTable StateCity = new DataTable();
Adapter.Fill(StateCity);
multiColumnCombo2.DataSource = StateCity;
Adapter.SelectCommand.Connection = ConSub;
Adapter.SelectCommand.CommandText = "Select * from groh";
DataTable groh = new DataTable();
Adapter.Fill(groh);
multiColumnCombo3.DataSource = groh;
Adapter.SelectCommand.Connection = ConSub;
Adapter.SelectCommand.CommandText = "Select * from activity where code_groh='" + Convert.ToInt32(multiColumnCombo3.Value.ToString()) + "'";
DataTable activity = new DataTable();
Adapter.Fill(activity);
multiColumnCombo4.DataSource = activity;
}
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{
moshtarakinhoghoghiBindingSource.AddNew();
if (phonebookDataSet.moshtarakin_hoghoghi.Compute("max(SysCode)+1", null).ToString() != null)
editBox1.Text = phonebookDataSet.moshtarakin_hoghoghi.Compute("max(SysCode)+1", null).ToString();
else
editBox1.Text = 1.ToString();
editBox3.Text = "";
editBox2.Text = "";
editBox4.Text = "";
multiColumnCombo1.Text = "";
multiColumnCombo2.Text = "";
multiColumnCombo3.Text = "";
multiColumnCombo4.Text = "";
uiComboBox1.Text = "";
}
private void multiColumnCombo1_TextChanged(object sender, EventArgs e)
{
if (multiColumnCombo1.Text != "")
{
SqlConnection ConSub = new SqlConnection("Data Source=.;Initial Catalog=phonebook;Integrated Security=True");
ConSub.Open();
SqlDataAdapter Adapter = new SqlDataAdapter("", ConSub);
Adapter.SelectCommand.Connection = ConSub;
Adapter.SelectCommand.CommandText = "Select * from StateCity where State_Id='" + Convert.ToInt32(multiColumnCombo1.Value.ToString()) + "'";
DataTable StateCity = new DataTable();
Adapter.Fill(StateCity);
multiColumnCombo2.DataSource = StateCity;
}
}
private void multiColumnCombo3_TextChanged(object sender, EventArgs e)
{
if (multiColumnCombo3.Text != "")
{
SqlConnection ConSub = new SqlConnection("Data Source=.;Initial Catalog=phonebook;Integrated Security=True");
ConSub.Open();
SqlDataAdapter Adapter = new SqlDataAdapter("", ConSub);
Adapter.SelectCommand.Connection = ConSub;
Adapter.SelectCommand.CommandText = "Select * from activity where code_groh='" + Convert.ToInt32(multiColumnCombo3.Value.ToString()) + "'";
DataTable activity = new DataTable();
Adapter.Fill(activity);
multiColumnCombo4.DataSource = activity;
}
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
try
{
moshtarakinhoghoghiBindingSource.EndEdit();
moshtarakin_hoghoghiTableAdapter.Update(this.phonebookDataSet.moshtarakin_hoghoghi);
}
catch
{
}
}
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{
if (moshtarakinhoghoghiBindingSource.Count > 0)
moshtarakinhoghoghiBindingSource.RemoveCurrent();
moshtarakinhoghoghiBindingSource.EndEdit();
moshtarakin_hoghoghiTableAdapter.Update(this.phonebookDataSet.moshtarakin_hoghoghi);
}
[/php]
|
|
|
|
|
How to trigger coded UI tests from C# code or can I draft mstest commands and trigger through process.start?But I have tried some ways but not helpful at all.
People here, can you help me get this done?
Vinod Chattergee
.Net Expert
http://mysourcecodes.blogspot.com/
|
|
|
|
|
vinod chattergee wrote: can I draft mstest commands Yup, command line switches are here[^]. I wrote a Tip[^] a while ago that shows how to fetch the latest code using a script and running both mstest and FxCop.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
But Eddy, I need to trigger it through C# code... I have the code written something like below
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(@"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe", "/testcontainer:" + testName + " /runconfig:\"C:\\MySecuredBrowser\\localtestrun.testrunconfig\" /nologo");
myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
But its not working....can anyone help?
Vinod Chattergee
.Net Expert
http://mysourcecodes.blogspot.com/
|
|
|
|
|
I'd first run that command from the command line, see if the switches are correct. Then take in account that your working-directory may vary.
Doesn't raise an exception, does it? As long as you are debugging/trying to get it to work, you may want to comment the line that hides the console; it may contain a hint on why it is not working. You can route the output to a file by appending "> output.txt" to the arguments.
As far as code goes, it looks like a correct way to start a process. The only other simplification I can come up with it putting all that inside a batch-file and call that using the Proces-class.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi, I want to implement SSO using SAML, C#. From current UI, i should redirect to another 3rd party application with authentication. Need advice on basics,.
|
|
|
|
|
What have you tried?
Where are you stuck?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
shank07ct wrote: Need advice on basics, Start with research[^].
|
|
|
|
|
Does anyone know if there is a way to assign a ProcessID the way you would assign a port for a socket?
It would make my life a whole lot simpler.
"I need build Skynet. Plz send code"
|
|
|
|
|
No. The process ID is assigned by the OS.
I'm curious - why would you want to assign a specific process ID to a process?
/ravi
|
|
|
|
|
trying to pull an end around a EULA
"I need build Skynet. Plz send code"
modified 21-Oct-14 10:34am.
|
|
|
|
|
I don't think so. You can, however, use Process.Id to identify your runnung app.
|
|
|
|
|
Member 9986689 wrote: You can, however, use Process.Id to identify your runnung app.
The problem here is that the process I was spawning was a daemon, and there is a battery of instances of the daemon all with the same process name...so without some way to either specify the processId of the child or persist its processId before the parent process died, there would be no way to attach to the proper instance (and the instances were not interchangeable)
I was able to work around this by adding a Configurator that attached the monitoring process to the daemon as it was being spawned.
...Being able to assign it an arbitrary ProcessID would have made the job easier and reduced the complexity of the implementation (not sure what justified the downvote of my original question)
"I need build Skynet. Plz send code"
|
|
|
|
|
What is better way to organise code of big project with
kilometers of code. And don't make mess of it.
My way is
using a1;
using a2;
namespace BasicLogic
{ class Form1:Form
{
..
}
...
}
File a1.cs
namespace a1
{...
}
File a2.cs
namespace a2
{...
}
Is it correct way? How to deal with and connecet other .cs files in project?
|
|
|
|
|
I like to organise my class files into the logical folder groups, which then in turn helps me manage my namespaces.
Each class file is responsible for a single object for example client, house etc.
I personally try to keep my namespace down to a maximum of 3 levels to hopefully keep the code easy to read.
They are most of what I do to try and organise a project with out going as far defining project layers (i.e. class libraries)
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Member 11151571 wrote: Is it correct way?
As long as the compiler knows what you mean, there is no wrong way.
The files don't matter as much as the logical structure of the code.
You will likely want a layered approach, each layer could be in its own Assembly.
I prefer lots of small files to provide granularity in version control.
|
|
|
|
|
There's a .NET framework with a lot of classes. It might help to look at how that code is grouped.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
A namespace per file doesn't strike me as a good way to do it: I generally arrange one namespace (maybe two or three) per assembly, with each class in one (preferably) or two files, and with the exception of embedded "helper" classes I wouldn't have more than one class per file either.
I generally create assemblies (and thus separate projects) for each logical group: Data Layer, Business Layer, Presentation layer for example would be three assemblies, each containing multiple classes and class files.
I am also a big fan of UserControls, generally having a separate assembly for them as well, and try to keep a form down to five or six controls only - which can be user controls containing more controls. This way, the amount of code in any one class is kept down, which make it easier to work with and understand.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thank you all.
To make it more clear and independent from control elemnents i wish to have component "Frames", what is in Delphi XE6. Just connect other frame to main form with coulpe of code lines.
|
|
|
|