|
C# is case sensative. Make sure logon is Logon when the method had capital letters.
|
|
|
|
|
Hello
I have one sql file which is having several lines of transact sql statement. I need to execute all commands in this file using ado.net ? How can i do that ? I tried putting that in sqlcommand object and tried with executenonquery. But it was not working ?
One more thing how can get the messaged send by sql server when running quefries like 0 rows affected or any other message
|
|
|
|
|
1. some code would be usefull in finding the problem.
2. the sql command object's ExecuteNonQuery returns an int that is the number of rows affected.
|
|
|
|
|
I mean i am going to run this query in command object
CREATE PROCEDURE dbo.sp_getDefaultPendingInvoiceToSend_new
(
@company_code varchar(30)
)
AS
if EXISTS (select * from INFORMATION_SCHEMA.tables where table_name = 'orderstemp')
drop table orderstemp
Declare @qry varchar(1500)
Set @qry='select distinct top 50 o.order_no into orderstemp from order_main o, PO_Main p, PO_Receipt_Main r where o.company_code='+''''+@company_code+''''+' and '
set @qry=@qry+'invoice_status !='+''''+'Complete'+''''+' and p.po_Code=r.PO_Code and p.order_no=o.order_no and 1=1 order by o.order_no desc'
print @qry
Exec(@qry)
DECLARE orderno_cursor CURSOR
FOR
select order_no from orderstemp
OPEN orderno_cursor
DECLARE @OrderQty int
DECLARE @ShippedQty int
DECLARE @OrderNo int
if EXISTS (select * from INFORMATION_SCHEMA.tables where table_name = 'TempOrderNo')
drop table TempOrderNo
CREATE TABLE TempOrderNo(order_no int,order_date varchar(20),Login_id varchar(100),order_net_value varchar(20))
FETCH NEXT FROM orderno_cursor INTO @OrderNo
WHILE (@@FETCH_STATUS <> -1)
BEGIN
print 'fetch status = ' + convert(varchar, @@FETCH_STATUS)
IF (@@FETCH_STATUS <> -2)
BEGIN
select @OrderQty= sum(item_qty) from order_detail where order_no=@OrderNo and company_code=@company_code
select @ShippedQty=sum(prd.Qty_shipped) from PO_Receipt_Detail prd, PO_Receipt_Main prm,PO_Main pm, order_main om
where om.order_no=@OrderNo and pm.order_no=om.order_no and om.company_code=@company_code and
pm.PO_Code=prm.PO_Code and prd.POR_Code=prm.POR_Code and om.invoice_status!='Complete' and pm.company_code=@company_code
print 'shipped qty is' + convert(varchar, @ShippedQty)
print 'order qty is' + convert(varchar, @OrderQty)
IF(@OrderQty=@ShippedQty)
insert into TempOrderNo select order_no,convert(varchar(20),order_date,110) as order_date,Login_id,
convert(varchar(20),net_order_value) as order_net_value
from order_main where order_no=@OrderNo and company_code=@company_code
END
FETCH NEXT FROM orderno_cursor INTO @OrderNo
END
CLOSE orderno_cursor
DEALLOCATE orderno_cursor
select top 10 * from TempOrderNo
drop table TempOrderNo
GO
|
|
|
|
|
do you want to know how to execute stored procedure through code ?
|
|
|
|
|
I need to make one query analyzer like what sql server do. so whatever sql commands typed in one textbox should be executed ?
|
|
|
|
|
I am working on a webcontrol that contains linkbuttons and I have to act on the click event of them. Can anyone help me to do this. I can not get it to work.
Matglas
|
|
|
|
|
Matglas wrote: I can not get it to work.
What exactly does that mean? What do you want to do when a link button is clicked? It would help if you show some code.
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
This is my code. When creating the child controls I add a linkbutton that has is linked to method viewLogLButton_Click(). But this method does not not execute. I deleted some original code because it was a lot longer.
[ToolboxData("<{0}:ExceptionViewer runat=server />")]
[DesignTimeVisible(true)]
public class ExceptionViewerControl : WebControl
{
protected override void RenderContents(HtmlTextWriter output)
{
this.EnsureChildControls();
this.RenderChildren(output);
}
protected override void OnInit(EventArgs e)
{
}
protected override void CreateChildControls()
{
this.Controls.Clear();
HtmlTable RenderTbl = LoadLogDirectory();
this.Controls.Add(RenderTbl);
}
private const string mainTblId = "exViewerTbl";
private String fileLoad = null;
private HtmlTable _mainFileTable = new HtmlTable();
private HtmlTable MainFileTable
{
get { return _mainFileTable; }
set { _mainFileTable = value; }
}
private HtmlTable LoadLogDirectory(FileInfo file)
{
this.MainFileTable = new HtmlTable();
LinkButton viewLogLButton = new LinkButton();
viewLogLButton.CommandName = "ViewLogFile";
viewLogLButton.CommandArgument = file.Name;
viewLogLButton.Text = file.Name;
viewLogLButton.Click += new EventHandler(viewLogLButton_Click);
ControlCollection controls = new ControlCollection(this);
controls.Add(viewLogLButton);
if (fileLoad == file.Name) {
}
this.MainFileTable.Rows.Add(GetHeaderRow(controls));
return MainFileTable;
}
void viewLogLButton_Click(object sender, EventArgs e)
{
fileLoad = ((LinkButton)sender).CommandArgument;
}
private HtmlTableRow GetHeaderRow(ControlCollection controls)
{
HtmlTableCell headerCell = new HtmlTableCell();
headerCell.Attributes["class"] = styleClass;
headerCell.Attributes["colspan"] = span.ToString();
foreach (Control ctrl in controls)
{
headerCell.Controls.Add(ctrl);
}
headerRow.Cells.Add(headerCell);
return headerRow;
}
}
Matglas
|
|
|
|
|
I'm quite sure it has something to do with dynamically adding the link button, but I do not know how to circumvent this. Try asking this in the ASP.NET forum.
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
remove this code
viewLogLButton.Click += new EventHandler(viewLogLButton_Click) from your LoadLogDirectory method then tranfer to OnInit Web Control EventHandler.
Here is a sample code...
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
viewLogLButton.Click += new EventHandler(viewLogLButton_Click);
}
regards,
Mark
|
|
|
|
|
Thanks I'll try it tomorrow when I am back at work.
Matglas
|
|
|
|
|
how to write code for treeview in visual c#
|
|
|
|
|
What do u want?
To create Nodes, Child Node?
|
|
|
|
|
i have create one application in which I have arrange group and subgroup as parent and child.how i can do it give me some projects related this.
|
|
|
|
|
i am looking for some examples on Lame encoder to capture a sound from my sound card and save it as Byte[]...and then play it
i did some search but found nothing ...
and if there any other solution better than Lame encoder or any other idea.
any thing to start with...
thanks allot
|
|
|
|
|
Hello,
I need a little feedback about how to make a little app in Net v1.1.
I need to find form with caption "<...>", find a button with caption "<...>" and press it.
Any ideas how to make it?
|
|
|
|
|
Hello,
Need more info about your program!
Do you have all the form instances in the class where you whant to find your form?
All the best,
Martin
|
|
|
|
|
There is running procces, which runs Form probrably writen in C++. Not managed.
Anyway, i need to find that window, and find a button with some text on in, and press it.
|
|
|
|
|
Hello,
OK,
Here is an example for an "OK" button.
using System.Runtime.InteropServices;
private const int BN_CLICKED = 245;
[DllImport("User32.dll")]
public static extern Int32 FindWindow(String lpClassName,String lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr lParam);
int hwnd=0;
IntPtr hwndChild=IntPtr.Zero;
hwnd=FindWindow(null,"XXX");
if(hwnd != 0)
{
hwndChild = FindWindowEx((IntPtr)hwnd,IntPtr.Zero,"Button","OK");
Thread.Sleep(1000);
SendMessage((int)hwndChild,BN_CLICKED,0,IntPtr.Zero);
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
Oh, it is possible to write only in managed code?
|
|
|
|
|
Hello,
Jefis wrote: possible to write only in managed code?
Not that I know! sorry
If you find a way, let us know!
All the best,
Martin
|
|
|
|
|
Mark T. wrote: Hi Martin, 27 Feb 2007
First, thanks for posting sample code. I have needed to do this same sort of thing in the past, and would like to learn how. (Pressing a button on a running program, or inserting text, or...)
I wrote a test program with a couple buttons on it, and then I tried your sample code. It successfully identified the other program's window (non-zero pointer), but could not find the button.
This call:
hwndChild = FindWindowEx((IntPtr)hwnd,IntPtr.Zero,"Button","A");
returned zero.
1. Any idea what may have gone wrong with this particular case.
2. Where can I learn more about this? For instance, I don't know where you found the value for BN_CLICKED = 245. I searched online and came up blank.
Thanks for any help.
Mark
Hello Mark,
Mark T. wrote: 1. Any idea what may have gone wrong with this particular case.
Is the Text Of your button really "A"?
Mark T. wrote: 2. Where can I learn more about this?
This is a good link:
http://www.codeproject.com/csharp/WindowsAPIsFromCS.asp[^]
P.S.: I'm not answering direct on e-mail questions.
All the best,
Martin
|
|
|
|
|
Hi all
I have Visual studio 2003 with just c# installed I have to read in a access database and show it using the smart device application. I sort of know how to do it on a normal app but as soon as i enter using System.Data.OleDb It cannot find on the smart device library. Is there way to read in a database and show it using a smart device app.
i.e. is there something else i can use apart from OleDb that can be found in smart device library. Oh if this stupid question or it in the wrong form can you tell me that as well
Can any one help
Thanks in advance
James_Bond
|
|
|
|
|
Hi,
I have an application in which there there is an MDI form and all other are its child. But when i try to show one specific form as its child, it does not appear. And also its Load event also does not fire. This form gets appeared from one location but not from any other location.
Can you please give me hint why it is so? Your help would be highly appreciated.
Regards,
Wasif Ehsan.
|
|
|
|