|
I am trying to call a stored procedure from C#. The stored procedure, called create_journal, compiles succesfully on SQL Server and also runs sucessfully when executed in query analyzeer. It takes a datetime input parameter. When I call it from C#, I get an SqlException which says Error 170. Line 1 Incorrect syntax near create_journal_entry
The stored Procedure begins as follows
ALTER PROCEDURE create_journal_entry
@eom_date DATETIME --End of month date
AS
DECLARE
@next_jrnl_num VARCHAR(20)
The c# code is
private void createJEs()
{
DateTime cutOffDate;
cutOffDate=this.dtpCutOffDate.Value;
SqlConnection conn =new SqlConnection(DBConnection.connectionString());
conn.Open();
SqlCommand comm=new SqlCommand("create_journal_entry",conn);
comm.Parameters.Add("@eom_date",SqlDbtype.DateTime);
comm.parameters["@eom_date"].value=this.dtpCutOffDate.Value;
try
{
comm.ExecuteNonQuery();
moveFiles();
MessageBox.Show("Data has been successfully sent to the
GL.", "Success",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
}
catch(SqlException ex)
{
MessageBox.Show("Error "+ex.Number + " "+ ex.Message,"SqlServer
error",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"System Error",
MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
finally
{
if (conn!=null)
{
conn.Close();
}
}
}
NB this.dtpCutOffDate is a DateTime picker control.
Please help as I am going nuts over this.
Thanks
|
|
|
|
|
You have to set your command object to stored proc type. i.e.
After this line
SqlCommand comm=new SqlCommand("create_journal_entry",conn);
Type this
comm.CommandType = CommandType.StoredProcedure
The default is text so it is reading 'create_journal_entry' as your query.
|
|
|
|
|
Thanks a batch! It worked right away......just wondering why the heck I could not see that. Feels like Friday.
|
|
|
|
|
I'd like to monitor a text file to see when an outside program changes the contents of it. Is there a simple way to do this??? Actually, the easiest way to do this for me might be to see when the it saves or closes.
|
|
|
|
|
|
You could check out FileSystemWatcher.. I can't remember if it'll tell you if the file's been opened or closed but it does let you know when a file has been changed, created, deleted etc... You can find it inside your ToolBox in Visual Studio
jay
|
|
|
|
|
Good deal. thank you both. I'm trying to make a PDF buttonclick event register in my code, but apparently this is very hard to do... So i decided to make the buttonclick in the PDF open and change a document. Then my C# app will hopefully see it and respond...worth a try any way. Thanks again.
jpc
|
|
|
|
|
According to this thread[^] it is possible if you're using Acrobat (not reader) with a little Java.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I have a simple scene in Direct3D in c#, but i am having trouble getting it to draw objects in the right order:
Image 1
Image 2 (Wrongness)
device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);<br />
device.BeginScene();<br />
device.VertexFormat = CustomVertex.PositionTextured.Format;<br />
<br />
LoadTexturesAndMaterials("TexFloor.png");<br />
device.SetTexture(0, texture);<br />
device.DrawUserPrimitives(PrimitiveType.TriangleList, 8, Floor);<br />
<br />
LoadTexturesAndMaterials("TexPillar.png");<br />
device.SetTexture(0, texture);<br />
device.DrawUserPrimitives(PrimitiveType.TriangleList, 16, MakePillar(new Vector3(fb, 0, 0), 4, 0.2f));<br />
device.DrawUserPrimitives(PrimitiveType.TriangleList, 16, MakePillar(new Vector3(-fb, 0, 0), 4, 0.2f));<br />
device.DrawUserPrimitives(PrimitiveType.TriangleList, 16, MakePillar(new Vector3(0, 0, -fb), 4, 0.2f));<br />
<br />
LoadTexturesAndMaterials("TexCrystal.png");<br />
device.SetTexture(0, texture);<br />
device.DrawUserPrimitives(PrimitiveType.TriangleList, 32, Crystal);<br />
<br />
device.EndScene();<br />
device.Present();<br />
Graphics g = this.CreateGraphics();<br />
g.DrawString("HUD Test", this.Font, Brushes.Red, new PointF(20, 20));<br />
this.Invalidate();<br />
|
|
|
|
|
|
Hi guys I am making a custom control/user control.
How make mycontrol.dosomething(); fire an event
and How do I handle event handlers
Thanks
|
|
|
|
|
public class MyControl : Control
{
public event EventHandler DoingSomething;
public void DoSomething()
{
OnDoingSomething(EventArgs.Empty);
}
protected virtual void OnDoingSomething(EventArgs e)
{
EventHandler eh = DoingSomething;
if(eh != null)
eh(this, e);
}
} The event handler for this event can be done in the same way as any other control.
See my Events Made Simple[^] article for more info including custom event args etc.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
|
Hello,
I have an application with datagrid that takes the information from database (bindingsource).
I have a refresh button to refresh the datagrids.
I want to make a button that the user will write which column from the DB he wants to add to the datagrid to see it's data.
How can i add programaticly new column that will be bound to this database?
|
|
|
|
|
Hi
sorry for post in this forum, because i Posted a message in this link[^] about workflow management standards in .net but noBody replied yet, hence i post again in this forum (and give a link for main question) to find out solution, It's very emergency.
Thanks
|
|
|
|
|
hdv212 wrote: It's very emergency
Looking at your profile: With your Silver membership, nearly 600 messages posted and almost 4 years as a member, you really should know better! It might be a good time to google for a flame suit[^].
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi DaveyM69
thanks for reply, but what's flame suit ?
does have relation with workflow ?
|
|
|
|
|
I have multiple instances of a custom control on a form. I created the control. I am able to use the Tab key to tab to the next control in the order but the Shift+Tab key will not tab to the previous control. The Shift+Tab key also causes the tab to the next control. I also have a couple of Buttons on the form. The Shift+Tab key functions correctly when the buttons have the focus. Can someone suggest why the Shift+Tab key will not shift focus to the previous control when my control has focus?
thanks
|
|
|
|
|
I am for the first time attempting to write a usercontrol for distribution. The control has an image window and a datagrid. My problem comes in trying to register the control for use in applications. I have been lost in the MSDN trying to get the code necessary to register this thing for use as a dll which can be drawn on your form like other windows controls. Does anyone have a template or a project similar that could guide me?
Densher
modified on Thursday, May 14, 2009 12:00 PM
|
|
|
|
|
I got a question first; do you want to make your code available for use in the .NET languages, or do you want to make the code available to 'most' languages (including, but not limited to .NET)?
For the first option, registering would be enough (regasm). For the second option you'd need to make an ActiveX control out of it (regsvr32).
I are troll
|
|
|
|
|
Basically, the control would target applications using VS 2005 and up including .Net as the development platform. I simply wish to enable the coder to draw the control on their form and interact as we did with the old OCX.
Densher
|
|
|
|
|
The user can right-click on the toolbox and add a reference to your assembly by selecting the DLL. You can register the assembly using regasm if you want it to show up in the list of possible .NET references.
I are troll
|
|
|
|
|
I believe you have mis-understood or I have mis-stated my need. I actually get the DLL to register with RegAsm. When I try to draw it on a form I get the error 80040154, CLSID not properly registered. Regasm reported completion successfully. From what I have been able to glean from the MSDN, I need some assembly statements for Interop and Enterprise Services and and possibly an interface. I need to know the structure of those code statements. Thanks for your time on this issue.
Densher
|
|
|
|
|
Hi All
I have a project in C# that I need to import C++ dll
In order to import it I’m using
[DllImport("CommunicationManagerDLL.dll")]
private static extern bool WiMAXGetState(ref eNDIS_802_16E_STATE NDIS_802_16E_STATE);
how can I send a pointer to struct to the dll ?
should I use ref?
Thanks
Ronen
|
|
|
|
|
This should work if you're struct is correct.
eNDIS_802_16E_STATE NDIS_802_16E_STATE interopStruct = new eNDIS_802_16E_STATE NDIS_802_16E_STATE();
bool result = WiMAXGetState(ref interopStruct);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|