Microsoft Access - insert into - Asked By jaison ignatius on 31-Jan-12 01:34 AM

form name : bill
table name <bill>
Bill no. -numeric type
total -numeric type
concern -text type

daybook
table name <daybook>

head : text type
Description: text type
income: numeric

I would like to insert value of bill no. & value of concern into description of Daybook while entering in form 

i.e numeric value and text value  eg. 1666 + minerva institute in daybook

thank you. 
Jitendra Faye replied to jaison ignatius on 31-Jan-12 01:39 AM
Follow this insert command example and use it-

protected void BtnInsert_Click(object sender, EventArgs e)
{

SqlConnection cn = new SqlConnection("YOUR CONNECTION STRING");

cn.Open();

string strQuery = "Insert into tablename(col1) values('" + TxtBox1.Text+ "') ";

SqlCommand cmd = new SqlCommand(strQuery, cn);

cmd.ExecuteNonQuery();

cn.Close();

}

Try this code and let me know.

Venkat K replied to jaison ignatius on 31-Jan-12 01:43 AM
There is no need to convert a numeric and string value, You can use the "&" operator and the number will be treated as string when concatenating...

ex:
=[PlantName] & [Category] & [Type] & Format([SeqNo],"0000")



smr replied to jaison ignatius on 31-Jan-12 01:44 AM
hi

try in this way

<asp:SqlDataSource ID="AddProductDataSource" runat="server" ConnectionString="..."
    InsertCommand="INSERT INTO Products(ProductName, CategoryID, UnitPrice, Discontinued) VALUES (@ProductName, @CategoryID, @UnitPrice, @Discontinued)"
    ProviderName="...">
   <InsertParameters>
    <asp:ControlParameter ControlID="ProductName" Name="ProductName" PropertyName="Text" />
    <asp:ControlParameter ControlID="Categories" Name="CategoryID" PropertyName="SelectedValue" />
    <asp:ControlParameter ControlID="UnitPrice" Name="UnitPrice" PropertyName="Text" />
    <asp:ControlParameter ControlID="Discontinued" Name="Discontinued" PropertyName="Checked" />
   </InsertParameters>
</asp:SqlDataSource>


follow
http://www.asp.net/web-forms/tutorials/data-access/accessing-the-database-directly-from-an-aspnet-page/inserting-updating-and-deleting-data-with-the-sqldatasource-vb
D Company replied to jaison ignatius on 31-Jan-12 01:48 AM
hello friend,

as you mentioned in your description,

Description: text type

than you can enter mixed type value just cancatinate it and insert using above post code.

Regards
D
Pat Hartman replied to jaison ignatius on 31-Jan-12 03:42 PM
There is no reason to store this calculated value since you can calculate it in a query whenever you need it.

Select ... [Bill No.] & " " & Concern As CalcValue
From ....

The ampersand "&" is the standard concatenation operator in VBA.  You can, under some conditions, also use the plus sign "+" for concatenation.  The two operands work differently with null values and you can use that to your advantage if you understand the difference.  Please read the help entries for both to understand the differences.   In the above example, I inserted a space between the two fields, you could use dashes, a colon, or some other separator if you prefer.

PS:  It is poor practice to include spaces and special characters in your column and table names.  Use CamelCase or The_Underscore to separate words to make names readable.
jaison ignatius replied to Pat Hartman on 31-Jan-12 11:07 PM
thanks.

jaison ignatius