Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 29th, 2004, 06:29 AM
Registered User
 
Join Date: Mar 2004
Location: Lahore, , Pakistan.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to simsimlhr Send a message via Yahoo to simsimlhr
Default Why normal insert querry doesnot work

I made connection with sql Server 2000.When Write Normal add querry
I gives error.Remember Insertion is in table.But When i write following code it works.

System.Data.SqlClient.SqlCommand
sqlInsertCommand1.CommandText="INSERT INTO Student(id) VALUES (@id)";
System.Collections.IEnumerator a=sqlInsertCommand1.Parameters.GetEnumerator();
a.MoveNext();
SqlParameter myParm=(System.Data.SqlClient.SqlParameter)a.Curre nt;
myParm.Value='12';
sqlInsertCommand1.ExecuteNonQuery();


I donot know why is so.Further more similar code for delete require all parameter in condition of delete querry.Thats not feasible.Can anybody tell me what is the problem.Why normal querry doesnot work.

Reply With Quote
  #2 (permalink)  
Old April 22nd, 2004, 06:10 AM
Authorized User
 
Join Date: Apr 2004
Location: pta, Gauteng, South Africa.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi (just joined today!!!)

System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(strConnectStri ng);
System.Data.SqlClient.SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "Insert into Clients(ClientID,Name,Surname,IDNo,PostalAddress,R esidentialAddress,
HomeTel," +
"Mobile,Remarks,BankName,BranchName,BranchCode,Acc ountNumber,
CardNumber," +
"ExpDate,PIN,TypeAccount,EmpNumber,Department,PayD ate,NettSal,EmployersID,UserID,Borrowing_Limit,Bla ckList)" +
"values('" + txtClientNum.Text + "','" + txtCustName.Text + "','"
+ txtSurname.Text + "','" + txtCustID.Text + "','" + txtPostal.Text + "','"
+ txtResid.Text + "','" + txtMobile.Text + "','"
+ txtHomeTel.Text + "','" + txtRemarks.Text + "','"
+ txtBankName.Text + "','" + txtBranch.Text + "','"
+ txtBranchCode.Text + "','" + txtAccNum.Text + "','"
+ txtCardNum.Text + "','" + txtExpDate.Text + "','"
+ txtPIN.Text + "','" + cbAccTypes.Text + "','"
+ txtEmpNum.Text + "','" + txtDept.Text + "','"
+ cbPayDate.Text + "','" + txtNettSal.Text + "','"
+ lblEmpID.Text + "','" + lblUsID.Text + "','" + txtBorrowLimit.Text + "','" + blacklist + "')";
cmd.CommandType = System.Data.CommandType.Text;
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();

This should work. The plus signs are for concatenation purposes.
This is the actual query that I use and it works everytime

jan

dude_in_africa
Reply With Quote
  #3 (permalink)  
Old January 9th, 2006, 03:26 AM
Authorized User
 
Join Date: Jan 2006
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have table name Id in which Id is the primary key.
I have one another table name Size ,I want to insert the values in size table for the value of field Id in Id table, So please tell me my Insert querry is of what type which makes joint of two table. by the way I am using access database
Please help me


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why doesn't this Insert Procedure work. beerOne ASP.NET 3.5 Basics 2 June 19th, 2008 09:59 AM
Insert won't work Tod1 Access VBA 1 December 18th, 2006 10:50 PM
Problem with insert querry Ashwini Classic ASP Databases 0 January 16th, 2006 07:17 AM
insert tigger dont work multiple kspiderman SQL Server 2000 1 October 21st, 2005 01:42 PM
Insert method doesnot work shoakat Classic ASP Databases 3 November 22nd, 2004 07:46 PM



All times are GMT -4. The time now is 09:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.