Click here to Skip to main content
15,910,981 members
Home / Discussions / C#
   

C#

 
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 
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 
I have try what you mentioned above but I still have an error...

this is the error:
An exception of type 'System.InvalidOperationException' occurred in MySql.Data.dll but was not handled in user code

Additional information: Connection must be valid and open.


c#:
C#
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

    {

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

        protected void btn_upload_Click(object sender, EventArgs e)
        {
            string constr = @"Data Source=192.168.8.124; Database=pmdb; User ID=client; Password=client";
            using (MySqlConnection con = new MySqlConnection(constr))
            {
            string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
            FileUpload1.SaveAs(@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf" + filename);
            con.Open();
            MySqlCommand cmd = new MySqlCommand("insert into work_inst(FileName,FileView) values(@Name,@Path)");

            cmd.Parameters.AddWithValue("@FileName", filename);
            cmd.Parameters.AddWithValue("@Path", @"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf");
            cmd.ExecuteNonQuery();
            Response.Write("Pdf File Save in Database");
            con.Close();
            BindGrid();
            }
        }
        /// </link>


    }
}

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 
GeneralRe: How do I set a DataGridVew column in a ListView BOLD? Pin
CHill608-Oct-15 6:34
mveCHill608-Oct-15 6:34 
QuestionAlert message script Pin
Member 120161066-Oct-15 15:31
Member 120161066-Oct-15 15:31 
AnswerRe: Alert message script Pin
Richard Andrew x646-Oct-15 16:22
professionalRichard Andrew x646-Oct-15 16:22 
GeneralRe: Alert message script Pin
Member 120161066-Oct-15 16:31
Member 120161066-Oct-15 16:31 
AnswerRe: Alert message script Pin
Richard Andrew x646-Oct-15 16:36
professionalRichard Andrew x646-Oct-15 16:36 
GeneralRe: Alert message script Pin
Member 120161066-Oct-15 16:53
Member 120161066-Oct-15 16:53 

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.