Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi

One of my table name is Items it has five fields ItemNo,Description,Qty,DoNumber and DoDate.

ItemNo,Description,Qty - values are from dynamic text box and i used datatable to save the value then inserting to database.

I need your suggestion how to add the value of DoNumber and DoDate to Item table.

DoNumber value i am generating from a method & for Dodate i have a text box.


Thanks
Posted
Comments
[no name] 15-Nov-11 2:55am    
What is the problem, even if you are creating dynamic text box you can get its text,and I think this is enough for you to add any value in database.
hilmisu 15-Nov-11 2:56am    
what do you want to know exactly? Do you need code sample for getting textbox value for your query? i do not understand clearly what's your question about?
Lancy.net 15-Nov-11 3:19am    
Hi Pranit and Hilmisu I am sorry this is my first project may be my question is wrong.
i am confused with this when i am adding the value of dynamic text box to datable can i add the value of other field also together? how to add? any links related to this?

C#
//using namespace when u use sql server//

using System.Data.SqlClient ;

// create sql connection //

sqlconnection con = new sqlconnection ("data souce= ur sql server name;initail catalog=ur database name;integreted security=true");
con.open();
sqlcommand cmd= new sqlcommand("insert into table_name values("'+textbox1.text+'","'+textbox1.text+'","'+textbox1.text+'")",con);
con.close();
 
Share this answer
 
v2
hey! please be more specific while asking question because your question is not clear for me. we need more information about your question.
whatever you can take a look there-MSDN-[How to: Insert New Records into a Database[^] to learn how to add values with step by step.
 
Share this answer
 
C#
string str=DoNumberMethod();//the method from which u want to pass the value for DoNumber .

sqlCommand cmd=insert into item values('"+txtItemNo.Text+"' , '"+txtQty.Text+"' , '"+txtDescription.Text+"' , '"+str+"' , '"+txtDoDate.Text+"')", sqlCon);


the return type for the method should be string :

C#
public string DoNumberMethod()
{
//return some string  value
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900