|
Hello,
Thanks for your help. I managed to find the answer. I don't need the line to add parameters. So l deleted it and made a few changes and now it works fine. Below is the correct code for your own review.
cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False";<br />
OleDbCommand cmdTeacher = cnnTeacher.CreateCommand();<br />
cmdTeacher.CommandText = "Select * From Teacher Where TeacherID = '" + txtIDNumber.Text + "' ";<br />
<br />
OleDbDataAdapter daTeacher = new OleDbDataAdapter(cmdTeacher);<br />
OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher);<br />
<br />
daTeacher.Fill(dtTeacher)
steve
|
|
|
|
|
Hi,
As a newbie, I was interested to read this article about creating a User Control.
support.microsoft.com/default.aspx?scid=kb;EN-US;323116
I copied the code from the webpage, compiled the user control code into a DLL, compiled the sample client application, and the progress bar worked fine.
I then started to tinker with it, and I found that my code did not work in all situations. I found that although the provided sample code drew the Progress Bar OK in the timer1Tick event handler, my button2Click event handler needed to call the Refresh method of the User Control. Without the refresh, the progress bar would not move at all until the "for" loop had finished, when it simply filled the whole bar. There was no progress at all, let alone smooth progress
The code I added to the sample on the MS site is below. Anyone know why this does not work without the Refresh? I'm guessing that maybe it's do do with the fact that in the supplied code, the Value is incremented once per event, whereas in my code, the increment from 1 to 100 is all in one event, and the repaint only occurs when the event handler completes. As I say, that's only a guess though.
Thanks in advance for any enlightenment.
Gary.
Here are the two Event Handlers.
void button2Click(object sender, System.EventArgs e)
{
for ( int i = 0; i <= 100; i++)
{
this.userControl12.Value = i;
// WHY DOES THIS NEED A REFRESH???
this.userControl12.Refresh();
}
}
void timer1Tick( object sender, EventArgs e )
{
if (this.userControl11.Value <= 100)
{
this.userControl11.Value++;
// BUT THIS DOESN'T???
}
else
{
this.timer1.Enabled = false;
}
}
|
|
|
|
|
|
This has to do with when Windows decides to repaint your form. Windows does not repaint until your application is idle. You have seen this before with programs that do heavy processing. Have you ever used a program and all the graphics went to a white screen, and you end up having to wait a few seconds to get the graphics back? That's the same principle. Here you are forcing the graphics to refresh on your own, without waiting for it to be called automatically by Windows. If you take out the refresh,then when you exit the button2click function, Windows calls a refresh automatically on your usercontrol, but by then the value is 100. So what you see is the progress bar at 100.
|
|
|
|
|
Hi,
I have a little problem when I am trying to use the SoapClient class from WSE 2.0 sp 1. I have to write a .NET application that must access some webservices written in Perl. I respect with the MS QuickStart samples the code that I wrote look like this:
Uri destUri = new Uri(http://82.77.28.243/site/arl/soap.tr/arac/tkn.ars);
ADotNetClient client = new ADotNetClient(destUri);
where:
[SoapService("http://schemas.company.net/arl/soap.tr/arac")]
public class ADotNetClient : SoapClient
{
public LoginClient(Uri to) : base(to)
{
}
[SoapMethod("http://schemas.company.net/arl/soap.tr/arac/tkn")]
public SoapEnvelope LoginSoap(SoapEnvelope envelope)
{
return base.SendRequestResponse("http://schemas.company.net/arl/soap.tr/arac/tkn#Get", envelope);
}
}
When a try to call LoginSoap I receive an error. Trying to solve the problem I traced the message which sent to the PerlWebServer and I found somehow the problem which appear to be in the HTTP header. Normally the first line of the http header should lool like this:
POST /vonc/arl/soap.tr/arac/tkn HTTP/1.1
but in my case look like this:
POST http://82.77.28.243/vonc/arl/soap.tr/arac/tkn HTTP/1.1
Pls explain to my why appear this and how can possibly solve the problem.
|
|
|
|
|
i would ask u 1 question in every tutorial has properties i see the get and set methods then in set it says MyString =
value ; in any tutorial it is value so what it means and is it a default one?
|
|
|
|
|
value is the implicit parameter used in setting accessors and to add or remove event handlers.
www.troschuetz.de
|
|
|
|
|
It lets you easily define access functions for a variable
In C++ you'd have something like
private:
int myint;
public:
int myint_get()
{
return myint;
}
void myint_set(int newval)
{
if( do some kind of check to make sure the value is valid )
{
myint = newval;
do any processing that has to happen if myint changes
}
}
so in the main code, if you want to increment the value of myint you'd have to do something like obj.myint_set(obj.myint_get()+1); which is somewhat messy
In C# access functions are made much tidier, like so
private int myint;
public int MyInt
{
get
{
return myint;
}
set
{
if( do some kind of check to make sure the value is valid )
{
myint = value;
do any processing that has to happen if myint changes
}
}
}
in other words, to answer your question value is whatever gets passed into the set function, i.e. obj.MyInt = 42; --then value would be 42
this lets you do stuff like obj.MyInt++; and treat it as if you'd just declared a public variable in the first place (without any of the worry about messing up your value)
You can make a read only variable by omitting the set{} part, or make it write only by omitting the get{} part if you so desire
NOTE: This code was just written off the top of my head - it's not expected to actually compile
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
I just wanted to include that if you look at any property that is generated with a setter method, the parameter name of the variable is always generated as value . For example, if you look at the InnerXml property of the XmlElement class (randomly chosen) you will see the following:
public override void set_InnerXml(string value)
{
this.RemoveAllChildren();
XmlLoader loader1 = new XmlLoader();
loader1.LoadInnerXmlElement(this, value);
}
With this logic you will see that the properties in C# simply generate getter and setter method with method signatures like set_[PropertyName] and get_[PropertyName].
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hı, My name is sait. I have a problem for this Registry and Eventlog.
in this way, now I haven't logon administration. but I want to while not have an admin to know write and Read to Registry and Eventlog file? Do you understant me? sorry I little speak and write english!
thank you very much... I wait to your answer...
Good evening...
|
|
|
|
|
You can read and write to certain areas of the eventlog and registry even if you are not logged in as an administrator.
For registry you can always read and write to HKEY-CURRENT-USER.
With the event log only administrators have access to the Security Log.
Does this help a little?
|
|
|
|
|
hi
i have the folloeing code . it always give me this error :
ERROR: Object reference not set to an instance of an object.
here is the code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Final
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.DataGrid dataGrid1;
private DataSet DS;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(80, 88);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(216, 88);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(56, 152);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(304, 152);
this.dataGrid1.TabIndex = 2;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(400, 350);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
addRC();
}
private void addRC()
{
DataTable test = new DataTable();
test.Columns.Add("students");
DataSet addRCDataSet = new DataSet("addRCDataSet");
addRCDataSet.Tables.Add(test);
dataGrid1.DataSource=addRCDataSet;
this.DS= addRCDataSet.Clone();
}
private void button1_Click(object sender, System.EventArgs e)
{
DataTable Dtable = DS.Tables["test"].Copy();
DataRow Dtr=Dtable.NewRow();
Dtr["students"]=textBox1.ToString();
Dtable.Rows.Add(Dtr);
DS.Tables.Remove("test");
DS.Tables.Add(Dtable);
}
}
}
can any 1 solve this problem 4 me ?
|
|
|
|
|
There are two quick solutions:
1) Add the following line to AddRc():
test.TableName = "test";
2) OR change the following line in button1_Click()
DataTable Dtable = DS.Tables["test"].Copy();
to
DataTable Dtable = DS.Tables[0].Copy();
Essentially you're trying to reference a table called test which does not exist (even though the object you created was called test - it does not mean the table name will be set to "test").
|
|
|
|
|
hi
thanx 4 u r help this fixe the problem . but i have a new problem now which is :
when i click the button 4 the first time the row will be added to the datagrid and i can C it but when i click the button again nothing happen and no data added to the data grid ?!!! any idea ? ? ? ?
|
|
|
|
|
Having quickly looked at the code.. I changed the following:
1) You don't want to clone the dataset since you won't be updating the one that is linked to the control.
Change the line
this.DS= addRCDataSet.Clone();
to
this.DS= addRCDataSet;
2) I modified the whole button1_click() method to:
private void button1_Click(object sender, System.EventArgs e)
{
object[] values = new object[1];
values[0] = textBox1.Text;
DS.Tables["test"].Rows.Add(values);
}
This just seemed a lot simpler to me - your earlier method was giving me problems.
|
|
|
|
|
It would be good to know which line of your code produces the error.
Anyway, by the given error message it's obvious that you try to use an object which wasn't instanciated yet.
So look which line causes the error and verify if you instanciated every object used there.
www.troschuetz.de
|
|
|
|
|
hi
i solve that problem but a new problem occure :
when i click the button 4 the first time the row will be added to the datagrid and i can C it but when i click the button again nothing happen and no data added to the data grid ?!!! any idea ? ? ? ?
|
|
|
|
|
Is there any chance in .NET to override standard look of Windows’ scroll bars (i.e. to make them be flat, change colors…) and then to attach them to standard controls: listbox, combobox, listview? Can I make my own scroll bar and attach it to mentioned controls?
|
|
|
|
|
Did you manage to solve your query? Because I would like to do the same! Please let me know!
Many thanks,
Richard
|
|
|
|
|
Hi...newbie here...yes it smells like an assignment but please if anyone can help with a formula on how to get this one.
My head is spinning....i've only got the inputs and im suppose to create a function not use the ones in the standard library.......pleasssse help with anything...................something......
^^^^^^^^^^^^^^^^
Write a function that takes the time as three integer arguments (hours, minutes and seconds) and returns the number of seconds since the last time the clock “struck 12.” Use this function in a program to calculate the amount of time in seconds between two times, both of which are within one 12-hour cycle of the clock.
|
|
|
|
|
Assuming you're only using 12 hour clocks and not 24 hour:
return (hour*60*60) + (minute*60) + second;
If my assumption is incorrect then you simply need to subtract 12 from hour if hour >= 12.
As for the second part - call the function twice and then take the absolute value of the difference of the two times.
|
|
|
|
|
Simply use the modulus operator to correct the hours value: (hour % 12)
The rest was already given by the previous post.
www.troschuetz.de
|
|
|
|
|
this is what i got...can anyone help integrating the formula suggested into this.........?
to make it simpler.....?
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
int main ()
{
int time(int,int,int);
int h,h2; // 0-23
int m,m2; // 0-59
int s,s2; // 0 -59
cout <<"Please enter 2 times: "<<endl;
cout<<"enter="" hour="" for="" the="" 1st="" time:="" "<<endl;
="" cin="">> h;
cout <<"enter minute for the 1st time: "<<endl;
cin="">> m;
cout <<"enter seconds for the 1st time : "<<endl;
cin="">> s;
cout <<"Please enter the 2nd time: "<<endl;
cout<<"enter="" hour="" for="" the="" 2nd="" time:="" "<<endl;
="" cin="">> h2;
cout <<"enter minute for the 2nd time: "<<endl;
cin="">> m2;
cout <<"enter seconds for the 2nd time : "<<endl;
cin="">> s2;
cout <<"According to the times entered,"<< endl;
cout<<"the difference between the two times in seconds is "<<time(h,m,s)- time(h2,m2,s2)
="" <<"="" seconds."<<="" endl;
="" return="" 0;
}
int="" time(int="" hh,int="" mm,int="" ss)
{
="" int="" min="0,sec" =0,sec2="0;
" if="" (hh="">12)
min = hh * 60;
sec = min * 60; //converts hours to seconds
if (mm>0)
sec2 = mm * 60; //converts minutes to seconds
int x = sec + sec2+ss; //total seconds
return x; //returns total seconds
|
|
|
|
|
Hi newbie,
Well this sounds like a mathematical function that you would have to make something like -
public int returnSecondsSinceTwelve(int hour, int minute, int second)
{
int timeSinceTwelve = 0;
if(hour > 12)
{
timeSinceTwelve = hour - 12;
}
else if(hour < 12)
{
timeSinceTwelve = hour;
}
timeSinceTwelve = timeSinceTwelve * 60 * 60;
minute = minute * 60;
return timeSinceTwelve + minute + second;
}
i havent tried this function so i dont gaurantee that it will work (i just wrote it roughly and really quick) but the basic theory is - to get seconds out of an hour multiply it by 60 (minutes) and then again by 60 (seconds) - to get seconds out of an minute multiply it by 60. Then add these all up (including second which is already in the right format) and you will get the total seconds. Hope this clears thins up.
|
|
|
|
|
Hi,
Does itextSharp support editing an existing pdf file.
We have a pdf template file with placeholders for different values that needs to be replaced with the actuals programmatically.
Basically kind of "Find and Replace" text values.Is this possible by itextSharp from sourceforget.net or any other pdf writer/generators.
TIA
|
|
|
|