|
If you are using SQL as a database, look into System.Data.SqlClient namespace. Or else, take a look into System.Data.OleDb namespace.
Check this[^] article.
modified on Monday, July 13, 2009 5:27 AM
|
|
|
|
|
Add namespace Using System.Data.SqlClient
Make SQLConnection object and pass the connection string to it.
eg :- SqlConnection con = new SqlConnection("paste Connection string here");
SqlCommand cmd;
cmd = new SqlCommand("Write Inserrt Query Here",con);
con.open();
cmd.ExecuteNonQuery();
con.close();
MessageBox.Show("Inserted");
|
|
|
|
|
Hi.. Heres the code for it...
Do appologize me if any error occurs merely due to my coding...
using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
SqlConnection con;
SqlCommand cmd;
string username,password,gender,empcode,dateofbirth,department;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
con = new SqlConnection();
con.ConnectionString = "Data source=.;Initial Catalog=Master;user id=sa;password=123";
con.Open();
MessageBox.Show("Connection Opened");
}
private void button1_Click(object sender, EventArgs e)
{
username = textBox1.Text;
password = textBox2.Text;
gender = textBox3.Text;
empcode = textBox4.Text;
dateofbirth = textBox5.Text;
department = textBox6.Text;
cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText="insert into employee values('"+username+"','"+password+"','"+gender+"','"+empcode+"','"+dateofbirth+"','"+department+"')";
cmd.Connection = con;
cmd.ExecuteNonQuery();
MessageBox.Show("Recods Inserted Successfully");
}
}
}
Hope this helps u out... If any error occurs do let us know about it...
Cheers,
Thashif
|
|
|
|
|
thnx for helping.....bt can u pls tell us the code if it is to be used for oledb instead of sql.....
|
|
|
|
|
I think in this case u can refer to the post mentioned by d@nish...
change the namespace and the query accordingly... Feel free 2 clarify ur doubts... Mentioning ur error msg will be more helpful...
Cheers,
Thashif
|
|
|
|
|
its just the same as sql... in place of sql type oleDb... Dont 4get to change the namespace too... in the connectionstring change it as "provider=MSDAORA;datasourse=xe;user id=ur userid;password=ur password";
Hope this helps out...
post the error msg if u have any...
Cheers,
Thashif
|
|
|
|
|
thanx a lot....the prblm has been solved.......
|
|
|
|
|
How do I instantiate an EntityObject with a Referencekeys for browsable objects.
I'd like to do an XML to LINQ then convert it back as an entity object. now my problem is when I do this.
GIVEN:
XML from store procedure
<Peoples>
<People>
<Name>name1</Name>
<Work><Work>
<Nickname>name1nick</Nickname>
</People>
</Peoples>
People --> EntityObject
People.Work --> Browsable Object (one to many relation)
People.NickName --> Extended property, not a EdmScalarPropertyAttribute (just a simple custom scalar string property)
var list = from peoples in XMLResult.Descendants("Peoples")
select new People
{
Name = peoples.Element("Name").Value,
Work = ??? (How do I load the this?), should I do (Work = _ObjectContext.Work.WorkID.Equals(peoples.Element("Work").Value), "Query in the object context?"
Nickname = peopls.Element("Nickname").Value
};
Now you might be thinking why not just do this...
var list = from people [ObjectContext].People
select people;
The reason is because People.NickName property is not a Table column, the data is generated from the stored procedure (which I had other processes) and is return as XML;
If i skip People.Work it would give an error. hope its clear.
|
|
|
|
|
Hi..
I need ur Help.
just give me simple logic
i Make a progrm users IN And OUT.I make a table in my database like USERNAME, DATE,INTIME, OUTTIME, when User come Select IN and click save button save in my database USERNAME, DATE,INTIME, after he going he select OUT save in my database in Same line just out timing of user.
Thanks In Advance
Jawad khatri
|
|
|
|
|
Find last IN status for user and update that row by upadating OUTTIME value.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Superficially the program logic looks easy, but there are some edge cases that you want to consider. What happens if your user chooses to select in twice without selecting out? When you code your application, you need to think about the different ways that the user interacts with it, and work out where they could go wrong. I normally find that sketching out a simple UI on a piece of paper helps to concentrate my mind on what can (and will) cause problems with my interface.
There are two approaches to solving the problem I just gave you. The first approach is to have the application prevent you from performing the IN operation if there's one that doesn't have an OUT operation. The second approach is to allow the application to perform the IN operation, but to warn them that they have a problem because they didn't log out before, and they need to seek help. The method you choose depends entirely on your business processes, so you need to take them into account.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
A few tips when asking questions here:
'Hello..' ==> bad subject line. It doesn't mean anything, doesn't help the people here to see on a fast glimpse what you'll be asking.
mjawadkhatri wrote: just give me simple logic
Bold text (and all capital letters) is considered shouting, and that is considered rude.
mjawadkhatri wrote: i
= I
mjawadkhatri wrote: progrm
= program
As to the actual question:
You'll need a simple GUI interface.
I'd make it so that they have to select there name (if it can be automated with a smart card or something that's even better) and click 'IN' or 'OUT'.
Then you'll have to catch those edge cases Pete talked about.
Basically put yourself in the place of the user and think of ways you can make the program crash / not work / not work like it should / ...
Because the user will find them sooner or later.
|
|
|
|
|
Hello,
I have written the following code to execute a script on a remote machine.
This works fine using the default login details.
How do I modify this code so that the user's credentials are used.
string strScriptPath = strTargetFullPath;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "cscript.exe";
process.StartInfo.Arguments = strScriptPath;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
try
{
process.Start();
}
catch (Exception ex)
{
}
Thanks
|
|
|
|
|
You can't. Impersonating the user remotely is a huge security risk and, therefore, not allowed. The remote script will always run as SYSTEM on the remote machine. You also cannot launch a process on a remote machine and expose a user interface. This too is a huge security risk and, again, not allowed.
|
|
|
|
|
hello folks,
i am creating an application where i am using a menubar.
now,i want to create it in such a way that,suppose i click on one menu,say data entry,the form should be opened in the same window.
at present,i have taken parentform so that i can make the menu consistent through out and i am using following code to open new window.
this.Hide();
Form2 frm = new Form2();
frm.ShowDialog();
this.Close();
this opens another window and closes the previous one.
and what i want is to open the form in same window without opening another form provided that
1. new form size fits in the window.
2. on closing the application only i can close the form.
3. on clicking next menu,this form is closed and another is opened without closing and reopening or opening a new form.
How can this be solved ??
|
|
|
|
|
IMO you should make use of MDI forms. Here[^] is an article to begin with.
Meth Ferrel wrote: 1. new form size fits in the window.
Set WindowState to maximized.
Meth Ferrel wrote: 2. on closing the application only i can close the form.
You mean just the child form? If yes, then on form closing of the Parent, check if there are any open forms. If found, just close the active child form. You can get the collection of OpenForms through Applciation.OpenForms . Note that this collection will also have the parent form.
Meth Ferrel wrote: 3. on clicking next menu,this form is closed and another is opened without closing and reopening or opening a new form.
Handle click event. Close the curently opened child form and open the next one.
|
|
|
|
|
dude...
i am not clear yet.
see...
basically i have taken MDIparent form.
what i want is,the MDI parent should not be closed,but below menu,there should be changes taking place on selecting the menu.
|
|
|
|
|
Handle the FormClosing event for the Parent. When you close it, check that if there is any open child. If you find it, then close that and cancel the closing of parent.
|
|
|
|
|
you are not at all getting my point dear.
what i am trying to say is,i just want to change all the forms according to the menu clicked.
The parent form shuold remain open.
i am using the code as
this.Hide();
form2.ShowDialog();
this.Close();
i have to change this code accordingly to fulfill my needs.
|
|
|
|
|
Meth Ferrel wrote: form2.ShowDialog();
If you are able to use ShowDialog, this means the form, is not the MDI child of the parent. If you are using MDIs, you will not be allowed to use ShowDialog for showing the child forms.
|
|
|
|
|
its the inherited form where the form is inherited by the mdiparent form.
i dont find any option as MDIChild in the add new item window.
|
|
|
|
|
Hey there,
Have you considered looking into MDI's? Here's a link for a bit of reading. I'm sorry I can't help you anymore than this as I have not used them myself, but I have heard alot about them being used for this reason.
Introduction to MDI Forms with C#[^]
Hope this helps.
Jase.
|
|
|
|
|
How Can I Get The Mac Address
|
|
|
|
|
|
What Is The Namespace To Do That
|
|
|
|