Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

astroudjr

@astroudjr
About
Posts
5
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Extracting an embedded resource file issue.
    A astroudjr

    When running the following code "stream" is null anyone see why? I'm a noob. Is there a better way to get my embedded resources out of my build?

    private static void ExtractFile()
    {
    Assembly Assemb = Assembly.GetExecutingAssembly();
    Stream stream = Assemb.GetManifestResourceStream("LockOut_NA.Properties.Resources.ECLock");
    FileStream fs = new FileStream(@"c:\ECLock1.htm",FileMode.CreateNew,FileAccess.Write);
    StreamReader Reader = new StreamReader(stream);
    StreamWriter Writer = new StreamWriter(fs);
    Writer.Write(Reader.ReadToEnd());
    }

    Thanks in advance.

    C#

  • ms access Stored Procedure - I am getting an empty DataSet when running a stored query
    A astroudjr

    I figured it out. It was the whole wildcard through the OleDb connection. I just changed the ?'s to #'s in the stored procedure and it worked fine.

    C# database tools help

  • ms access Stored Procedure - I am getting an empty DataSet when running a stored query
    A astroudjr

    I run the query in access and it populates results fine. It is a simple select command. I think I might just have the code wrong somewhere just can't figure it out. Please help. The headers populate in the datagridview but none of the data does.

    private void QueryTest()
    {
    pcDataConn = Utility.DBConnection();
    try
    {
    OleDbCommand cmd = new OleDbCommand();
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Connection = pcDataConn;
    cmd.CommandText = "FHD_qry";
    DataSet ds = new DataSet();
    OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
    adapter.Fill(ds);
    DataTable dt = ds.Tables[0];
    pcDataview.DataSource = dt;
    int totalResults = dt.Rows.Count;
    Resultslabel.Text = "Results: " + dt.Rows.Count.ToString();
    if (totalResults > 0)
    {
    Exportbutton.Enabled = true;
    }
    else
    {
    Exportbutton.Enabled = false;
    }

            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
            pcDataConn.Close();
         }
    
    C# database tools help

  • Trouble updating DataGridView.Datasource in a different class - Error "An object reference is required for the non-static field, method, or property"
    A astroudjr

    That is actually how I had it running initially within Form1. But I have another method within the Utility Class That logs the transactions and I wanted to be able to just update the datagridview after every log, so I would still need to use it from this class. I just turned it into a button click for testing. I hope this makes sense.

    C# csharp database tools help

  • Trouble updating DataGridView.Datasource in a different class - Error "An object reference is required for the non-static field, method, or property"
    A astroudjr

    this is my first C# project so bear with me. Here is the code. HistoryDataView is part of Form1 and is set to public.

    namespace LockOut
    {
    public partial class Utility : Form
    {
    public Form1 m_parent;
    public Utility(Form1 frm1)
    {
    m_parent = frm1;
    }
    public static DataTable DeviceHistory()
    {
    OleDbConnection pcDataConn = DBConnection();
    try
    {
    DataSet ds = new DataSet();
    string SQL = "SQL Statement";
    OleDbDataAdapter adapter = new OleDbDataAdapter();
    adapter.SelectCommand = new OleDbCommand(SQL, pcDataConn);
    adapter.Fill(ds);
    DataTable dt = new DataTable();
    dt = ds.Tables[0];
    if (dt.Rows.Count < 1)
    {
    dt = null;
    }
    pcDataConn.Close();
    return dt;
    }
    catch(Exception ex)
    {
    pcDataConn.Close();
    DataTable dt = null;
    Console.WriteLine(ex.Message.ToString());
    return dt;

            }
        }
        public static void UpdateDeviceHistory()
        {
            **m\_parent.HistoryDataView.DataSource** = DeviceHistory(); //<-- Here is where the error is generated
        }
    

    }

    namespace LockOut
    {
    public partial class Form1 : Form
    {
    private void Refresh_Click(object sender, EventArgs e)
    {
    Utility.UpdateDeviceHistory();
    }
    }
    }

    C# csharp database tools help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups