Showing posts with label saved. Show all posts
Showing posts with label saved. Show all posts

Monday, March 19, 2012

adding sql db

hey i have a very simple form here:www.syscpupower.com

I would like to have the information from the form saved to a sql db with a time stamp.

here is the code i have for the page below:

"C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >"server"> "form1" runat="server">


"z-index: 108; left: 0px; position: absolute; top: 189px">

"z-index: 109; left: 204px; width: 411px; position: absolute; top: 18px; height: 160px">"3" rowspan="3" style="text-align: center"> Please accept to view your detailed trip information.

"Button1" runat="server" OnClick="Button1_Click" Style="z-index: 102; left: 322px; position: absolute; top: 261px" Text="Accept" Width="60px"> "Button2" runat="server" OnClick="Button2_Click" Style="z-index: 103; left: 392px; position: absolute; top: 261px" Text="Decline" Width="64px"> "Label1" runat="server" Style="z-index: 104; left: 254px; position: absolute; top: 198px" Text="Please Enter Your First and Last Name!" Width="273px"> "TextBox1" runat="server" Style="z-index: 105; left: 278px; position: absolute; top: 229px" Width="216px"> "RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="FirstName LastName" Font-Size="12px" Style="z-index: 106; left: 500px; position: absolute; top: 229px">* "ValidationSummary1" runat="server" Style="z-index: 110; left: 263px; position: absolute; top: 300px" Width="284px">

sorry, what exactly you want?

you want to know how to insert information to db?

or you want to know how to create db for it?

|||well i created the db, now i guess i need to findo out how to get the info from the text box into the database...|||

using (SqlConnection sc = new SqlConnection("Data Source=(local);Initial Catalog=AAAA;Integrated Security=SSPI;"))
{

string strSQL = "INSERT INTO tbXXXX(NAME) VALUES(TextBox1.text)
SqlCommand command = new SqlCommand(strSQL, sc);
command.Connection.Open();
command.ExecuteNonQuery()
}

|||

i have added the SQL database, THATS it...

I see the code that you have put here can you please explain the coding, how did you get this and where does it go in the coding. alsodi i need to create tables inside my db.

|||

Hey

You could double click button in design mode and add above code.

Above code follows those steps:

Create a connection -> build the sql -> create sql command ->open connection ->exec insert-> close command.

And to prevent Sql Inject you could choose sql parameter,it could be something like this:

SqlCommand cmd = new SqlCommand("select column1 from test where column1 = @.column1", conn);

cmd.Parameters.AddWithValue("@.column1", str_test);

If you are in trouble understanding the codeStarter Books might be helpful.

Saturday, February 25, 2012

adding image dynamically to crystal report

hello
please could anyone help me to insert an image into crystal report if I saved the link in the database . I tried to change the type to "ole object" it works, but i don't have to change the type in my project.If you are using SQL Server then search for TextCopy.exe, you will get lot of related code.|||it is very easy in the Crystal 11.5 and later.

Place the OLE object -> Bitmap Image on the report. Right click the OLE Object -> Format Graphics -> Picture (tab) -> Graphic Location.

And enter the URL where the image file is placed.
Now the crystal Report will show the image on runtime by picking from the location mentioned.|||i'm using v8.0 , i'll download the XI version and I'll try