Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: Project Explanation Pin
Mycroft Holmes8-Oct-15 20:16
professionalMycroft Holmes8-Oct-15 20:16 
GeneralRe: Project Explanation Pin
OriginalGriff8-Oct-15 21:44
mveOriginalGriff8-Oct-15 21:44 
QuestionConvert Json to C# Pin
Waqas Ahmad8-Oct-15 7:55
Waqas Ahmad8-Oct-15 7:55 
AnswerRe: Convert Json to C# Pin
Richard Deeming8-Oct-15 9:19
mveRichard Deeming8-Oct-15 9:19 
QuestionSave Stream from Multiple IP Camera Pin
Enobong Adahada8-Oct-15 5:33
Enobong Adahada8-Oct-15 5:33 
AnswerRe: Save Stream from Multiple IP Camera Pin
CHill608-Oct-15 6:21
mveCHill608-Oct-15 6:21 
GeneralRe: Save Stream from Multiple IP Camera Pin
Enobong Adahada8-Oct-15 11:53
Enobong Adahada8-Oct-15 11:53 
QuestionUpload pdf file in MySQL.... Pin
Member 120161068-Oct-15 0:40
Member 120161068-Oct-15 0:40 
I wanted to upload my pdf files in MySQL and view from datagrid....
I have an error...This is the error..
"
Additional information: Could not find a part of the path 'C:\WSmfgIT\WSmfgIT\WSmfgIT\wsmfgit\wsmfgit\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction
"


asp.net:
XML
<asp:Button ID="btn_upload" runat="server" style="z-index: 1; left: 610px; top: 337px; position: absolute; height: 23px; width: 63px" Text="Upload" OnClick="btn_upload_Click" />
<!---GridView----->
   <div>
        <asp:GridView ID="workinstruc" CssClass="Gridview" runat="server" AutoGenerateColumns="false" DataKeyNames="FileView"  >
            <HeaderStyle BackColor="#df5015" />
           <Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="FileName" HeaderText="FileName" />
<asp:TemplateField HeaderText="FileView">
<ItemTemplate>
    <asp:LinkButton ID="lnkView" runat="server" Text="View" ></asp:LinkButton>
</ItemTemplate>
    </asp:TemplateField>
</Columns>
        </asp:GridView>
<!--End GridView--->


c#:
<pre lang="cs">using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.Windows.Forms;
using System.Data;
using MySql.Data.MySqlClient;


namespace wsmfgit
{
    public partial class workinstruction : System.Web.UI.Page

    {

        /// &lt;connect DB&gt;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.BindGrid();
            }
        }
        private void BindGrid()
        {
            string constr = @&quot;Data Source=192.168.8.124; Database=pmdb; User ID=client; Password=client&quot;;
            using (MySqlConnection con = new MySqlConnection(constr))
            {
                using (MySqlCommand cmd = new MySqlCommand(&quot;SELECT ID, FileName, FileView FROM work_inst&quot;))
                {
                    using (MySqlDataAdapter sda = new MySqlDataAdapter())
                    {
                        cmd.Connection = con;
                        sda.SelectCommand = cmd;
                        using (DataTable dt = new DataTable())
                        {
                            sda.Fill(dt);
                            workinstruc.DataSource = dt;
                            workinstruc.DataBind();
                        }
                    }
                }
            }
        }
        ///&lt;/connect&gt;
        /// &lt;link to home button&gt;
        protected void imgbtn_home_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect(&quot;default.aspx&quot;);
        }

        protected void btn_upload_Click(object sender, EventArgs e)
        {
            string constr = @&quot;Data Source=192.168.8.124; Database=pmdb; User ID=client; Password=client&quot;;
            using (MySqlConnection con = new MySqlConnection(constr))
            {
            string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
            FileUpload1.SaveAs(Server.MapPath(@&quot;\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf&quot; + filename));
            con.Open();
            MySqlCommand cmd = new MySqlCommand(&quot;insert into work_inst(FileName,FileView) values(@Name,@Path)&quot;);
            cmd.Parameters.AddWithValue(&quot;@FileName&quot;, filename);
            cmd.Parameters.AddWithValue(@&quot;\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf&quot;,filename);
            cmd.ExecuteNonQuery();
            Response.Write(&quot;Pdf File Save in Database&quot;);
            con.Close();
            BindGrid();
            }
        }
        /// &lt;/link&gt;


    }
}
</pre>


This are my code...could anyone help me...
AnswerRe: Upload pdf file in MySQL.... Pin
CHill608-Oct-15 1:52
mveCHill608-Oct-15 1:52 
GeneralRe: Upload pdf file in MySQL.... Pin
Member 120161068-Oct-15 15:13
Member 120161068-Oct-15 15:13 
AnswerRe: Upload pdf file in MySQL.... Pin
Pete O'Hanlon8-Oct-15 2:01
mvePete O'Hanlon8-Oct-15 2:01 
GeneralRe: Upload pdf file in MySQL.... Pin
Member 120161068-Oct-15 15:19
Member 120161068-Oct-15 15:19 
AnswerRe: Upload pdf file in MySQL.... Pin
Richard Deeming8-Oct-15 2:10
mveRichard Deeming8-Oct-15 2:10 
GeneralRe: Upload pdf file in MySQL.... Pin
Member 120161068-Oct-15 15:30
Member 120161068-Oct-15 15:30 
GeneralRe: Upload pdf file in MySQL.... Pin
Richard Deeming9-Oct-15 1:52
mveRichard Deeming9-Oct-15 1:52 
GeneralRe: Upload pdf file in MySQL.... Pin
Member 1201610611-Oct-15 15:04
Member 1201610611-Oct-15 15:04 
Questionlocking an app on request Pin
Member 116417407-Oct-15 23:32
Member 116417407-Oct-15 23:32 
AnswerRe: locking an app on request Pin
Dave Kreskowiak8-Oct-15 3:28
mveDave Kreskowiak8-Oct-15 3:28 
AnswerRe: locking an app on request Pin
BillWoodruff8-Oct-15 19:47
professionalBillWoodruff8-Oct-15 19:47 
QuestionHow do I set a DataGridVew column in a ListView BOLD? Pin
Robert Oujesky7-Oct-15 11:10
Robert Oujesky7-Oct-15 11:10 
AnswerRe: How do I set a DataGridVew column in a ListView BOLD? Pin
Matt T Heffron7-Oct-15 12:26
professionalMatt T Heffron7-Oct-15 12:26 
AnswerRe: How do I set a DataGridVew column in a ListView BOLD? Pin
CHill607-Oct-15 13:01
mveCHill607-Oct-15 13:01 
GeneralRe: How do I set a DataGridVew column in a ListView BOLD? Pin
Robert Oujesky8-Oct-15 5:44
Robert Oujesky8-Oct-15 5:44 
GeneralRe: How do I set a DataGridVew column in a ListView BOLD? Pin
CHill608-Oct-15 6:20
mveCHill608-Oct-15 6:20 
GeneralRe: How do I set a DataGridVew column in a ListView BOLD? Pin
Robert Oujesky8-Oct-15 6:28
Robert Oujesky8-Oct-15 6:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.