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
U

Uranium 235

@Uranium 235
About
Posts
31
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Refreshing data on a parent form at child close
    U Uranium 235

    yeah I know about try...finally some generics and heh yeah overloading is beyond me. I've read about it and seen code samples, and delegates I have a blurry idea at best, because I have seen other code samples but yeah the base concept will have to be learned in a basic to advanced way a book does again this program is easy, well...yeah I did have that big problem, but I overcame it. It's simple database and form stuff. I know a good amount about databases already with my time using php/mysql, but yeah I know there is a unifying sql subsystem in c# I haven't played with that has to do with sources, and binding, etc

    C# database debugging sales regex help

  • Refreshing data on a parent form at child close
    U Uranium 235

    wow $40. I'm not going to be making any money off my code so and it's a program just for me (and an easy one at that), i'll probably skip this, at least for the time being

    C# database debugging sales regex help

  • Refreshing data on a parent form at child close
    U Uranium 235

    google searches, guesswork. But as you can tell from my code i'm not doing TOO bad. I know some of the .net concepts, and did pretty well with vb.net (but I hate the syntax of vb.net) did borland C++ in high school and a little in college to get me past the required single beginning programming class (my comp sci was focused for computer repair)

    C# database debugging sales regex help

  • Refreshing data on a parent form at child close
    U Uranium 235

    I tried, and got errors, even downloaded the zip and it's pretty confusing. Keep in mind i've been doing c# for like, two weeks? Gotten fairly far using just google searches. Some specific things do elude me. Like your code. Still have a lot of specific stuff to figure out. like things like seeing {get; set;} at top and things like that I just don't understand. Mind you this program is going to be used by just me, nor will I be doing any business-level programming. I did some of that with PHP but never continued and never learned ajax/dhtml, which a lot of web sites require. My specialty is repair/support (which this program is for me to keep track of that) aaaanyways, I found a solution, that I think I did put in my original post, but just using .show allowed my original form call to create a FormClosedEventHandler from the parent, which works. So now the child is doing nothing aware from the parent...sort of

    C# database debugging sales regex help

  • Refreshing data on a parent form at child close
    U Uranium 235

    lol I actually ran across that page during my research. It sounds real complicated. a little blood just dropped from my nose

    C# database debugging sales regex help

  • Refreshing data on a parent form at child close
    U Uranium 235

    I've worked a lot to try to get this working, but after several errors and trials, i've tried two things without error, but it doesn't work here is my customer list load code

           SQLiteParameter\[\] param = {};
           // MessageBox.Show("ran?");
            customerList.Rows.Clear();
    
            DataTable searchinfo = database.query\_search("SELECT id, firstname, lastname FROM customers", param);
    
            foreach (DataRow row in searchinfo.Rows)
            {
                customerList.Rows.Add(row\[0\].ToString(), row\[1\].ToString() + " " + row\[2\].ToString());
            }
            statusLabel.Text = searchinfo.Rows.Count.ToString() + " row(s) returned";
    

    double clicking or clicking an 'edit' button successfully raises a child form

        private void customerList\_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int index = e.RowIndex;
    
            DataGridViewRow row = customerList.Rows\[index\];
            String cid = row.Cells\[0\].Value.ToString();
    
            editcustomer editdiag = new editcustomer();
            editdiag.id = cid;
            editdiag.ShowDialog();
        }
    

    I used a timer to filter results from a textbox that starts and stops based on textchanged

        private void search\_TextChanged(object sender, EventArgs e)
        {
            if(queryInterval.Enabled == false)
                queryInterval.Start();
        }
    

    here is the 1000ms tick that stops itself after an idle match

        public void queryInterval\_Tick(object sender, EventArgs e)
        {
            if (lastQuery == search.Text)
            {
                queryInterval.Stop();
            }
            else
            {
                if (search.Text.Trim() != "" && search.Text.Length >= 3)
                {
                    customerList.Rows.Clear();
    
                    SQLiteParameter\[\] param = {
                    new SQLiteParameter("@search", "%" + search.Text + "%") //used direct string for debug //search.Text)
                };
    
                    DataTable searchinfo = database.query\_search("SELECT id, firstname, lastname FROM customers WHERE firstname LIKE @search OR lastname LIKE @search", param);
    
                    foreach (DataRow row in searchinfo.Rows)
                    {
                        customerList.Rows.Add(row\[0\].ToString(), row\[1\].ToString() + " " + row\[2\].ToString());
                    }
    
    C# database debugging sales regex help

  • No rows returned using SQLiteParameters, but rows returned with direct query
    U Uranium 235

    I thought SQLLiteParameter sanitizes or at least escapes special characters

    Database database sqlite com debugging help

  • No rows returned using SQLiteParameters, but rows returned with direct query
    U Uranium 235

    it's a search query for a database, text input box

    Database database sqlite com debugging help

  • No rows returned using SQLiteParameters, but rows returned with direct query
    U Uranium 235

    yes, but if it's put into the textbox, it's queried as LIKE %%% which matches everything

    Database database sqlite com debugging help

  • No rows returned using SQLiteParameters, but rows returned with direct query
    U Uranium 235

    do you know why the % char isnt being escaped?

    Database database sqlite com debugging help

  • No rows returned using SQLiteParameters, but rows returned with direct query
    U Uranium 235

    tried and failed. wait, using it without ' in the query string works. yes, thank you though I can still input % as a wildcard and get all rows. I thought this supposed to sanitize/escape input. guess I can live with it though, unless you have a better idea

    Database database sqlite com debugging help

  • No rows returned using SQLiteParameters, but rows returned with direct query
    U Uranium 235

    Ok, here is the code in my class

       static public DataTable query\_search(string sqlite\_query, SQLiteParameter\[\] parameters)
        {
            SQLiteConnection sqlite\_conn = new SQLiteConnection("Data Source=test.db;Version=3;Compress=True;Synchronous=Full;");
    
            sqlite\_conn.Open();
            SQLiteCommand sqlite\_cmd;
            sqlite\_cmd = sqlite\_conn.CreateCommand();
            sqlite\_cmd.CommandText = sqlite\_query;
            SQLiteDataReader sqlite\_datareader;
    
            sqlite\_cmd.Parameters.AddRange(parameters);
            sqlite\_datareader = sqlite\_cmd.ExecuteReader();
    
            DataTable returnTable = new DataTable();
            returnTable.Load(sqlite\_datareader);
    
            writedebug(returnTable.Rows.Count.ToString());
    
            sqlite\_conn.Close();
            sqlite\_datareader.Close();
            return returnTable;
        }
    

    writedebug writes 0 rows My call

        private void button1\_Click(object sender, EventArgs e)
        {
            if (search.Text.Trim() != "")
            {
    
                SQLiteParameter\[\] param = {
                    new SQLiteParameter("%@search%", "paul") //used direct string for debug //search.Text)
                };
    
                customerList.Rows.Clear();
    
                DataTable searchinfo = database.query\_search("SELECT id, firstname, lastname FROM customers WHERE firstname LIKE '@search' OR lastname LIKE '@search'", param);
    
                MessageBox.Show(searchinfo.Rows.Count.ToString());
               
                foreach (DataRow row in searchinfo.Rows)
                {
                    customerList.Rows.Add(row\[0\].ToString(), row\[1\].ToString() + " " + row\[2\].ToString());
                }
            }
        }
    

    if I replace @search in the query with "%paul%" (in the database) writedebug turns 2 and it adds the rows to the form table I can query and put the search.Text directly into the string like SELECT id, firstname, lastname FROM customers WHERE firstname LIKE '" + search.Text + "' OR lastname LIKE '" + search.Text + '" but I needed sanitized queries (even though im the only one using this software), adding a % will make it return all rows I've used SQLiteParameter for INSERT INTO with another function successfully. please help thanks

    Database database sqlite com debugging help

  • Getting data from simple SQLite table returns NULL
    U Uranium 235

    Nevermind. I inserted it into the database with a query in DB Browser instead of using the browser and it seemed to work :shrug: thanks for putting up with me

    Database database csharp mysql sqlite question

  • Getting data from simple SQLite table returns NULL
    U Uranium 235

    no this is from DB Browser, not even the app

    Database database csharp mysql sqlite question

  • Getting data from simple SQLite table returns NULL
    U Uranium 235

    no, that wasn't a copy & paste, it was a misspelling here, when I actually do it from my c# app it returns the column names (found a function to easily present col names and row data, so the columns are correct), and one row of empty data, just like in DB Browser I just tried SELECT * FROM "main"."appinfo"; it returned , 0, the middle number is supposed to be a 1

    Database database csharp mysql sqlite question

  • Getting data from simple SQLite table returns NULL
    U Uranium 235

    i'm used to MySQL, this is...different. A table with just one row Using "DB Browser for SQLLite"...structure CREATE TABLE "appinfo" ( "version" TEXT NOT NULL, "passworded" INTEGER NOT NULL, "username" TEXT NOT NULL ); I added a row. "1", 1, "Admin" with DB Browser when I query it "SELECT * FROM addinfo;" with DB browser I get NULL for each field (blank on my c# app) what am I missing here? thanks

    Database database csharp mysql sqlite question

  • c# forms (holy crap i'm not ready for this)
    U Uranium 235

    wait a second I used this

    DataTable returnTable = new DataTable();
    DataColumn dtColumn;
    DataRow dataRow;

            MessageBox.Show(fieldCount.ToString());
    
            for (int i = 0; i <= (fieldCount - 1); i++)
            {
                //MessageBox.Show(sqlite\_datareader.GetDataTypeName(i));
    
                switch (sqlite\_datareader.GetDataTypeName(i))
                {
                    case "TEXT":
                        dtColumn = new DataColumn();
                        dtColumn.DataType = typeof(String);
                        dtColumn.ColumnName = sqlite\_datareader.GetName(i);
                        returnTable.Columns.Add(dtColumn);
                    break;
    
                    case "INTEGER":
                        dtColumn = new DataColumn();
                        dtColumn.DataType = typeof(Int32);
                        dtColumn.ColumnName = sqlite\_datareader.GetName(i);
                        returnTable.Columns.Add(dtColumn);
                    break;
                }
            }
    
    
    
            for (int j = 0; sqlite\_datareader.Read(); j++)
            {
                for (int k = 0; (k <= fieldCount - 1); k++)
                {
                    MessageBox.Show(sqlite\_datareader.GetDataTypeName(k));
                    MessageBox.Show(sqlite\_datareader.GetName(k));
    
                    switch (sqlite\_datareader.GetDataTypeName(k))
                    {
    
                        case "TEXT":
                            dataRow = returnTable.NewRow();
                            dataRow\[sqlite\_datareader.GetName(k)\] = sqlite\_datareader.GetString(k);
                            returnTable.Rows.Add(dataRow);
                            //returnTable.Rows.Add(sqlite\_datareader.GetString(k));
                            break;
    
                        case "INTEGER":
                            dataRow = returnTable.NewRow();
                            dataRow\[sqlite\_datareader.GetName(k)\] = sqlite\_datareader.GetInt32(k);
                            returnTable.Rows.Add(dataRow);
                            //returnTable.Rows.Add(sqlite\_datareader.GetString(k));
                            break;
                    }
    
                }
                  \*/
    

    to try to load the query into a datatable (unsuccessfully, datatype problems), and you can just use .load()? That was a day well wasted

    .NET (Core and Framework) csharp php database help

  • c# forms (holy crap i'm not ready for this)
    U Uranium 235

    oh duh I needed to specify 'Array' but now I get

    Array SQLLiteReader Row[];
    ^^^
    "; expected"
    ^
    identifier expected

    .NET (Core and Framework) csharp php database help

  • c# forms (holy crap i'm not ready for this)
    U Uranium 235

    ok, been working on it, i'd figure i'd just add to this instead of making a new thread. I've been messing with SQLite. What I want is to make a function to run the query, get row data and return it. Of course, rows are of mixed types, Using GetDataTypeName(), but storing these into an array is impossible because arrays can only be one type is there a way to store the row data into an array? I've tried the reader row data itself, but i'm not sure i'm going about it the right way this is the core section i'm trying. I've successfully done the query and got the data inside the function, just returning it is the problem

    sqlite\_cmd = sql\_conn.CreateCommand();
    sqlite\_cmd.CommandText = sql\_query;
    sqlite\_datareader = sqlite\_cmd.ExecuteReader();
    
    SQLLiteReader Row\[\];
    
    
    //store reader data in an array?
        for(int i = 0; sqlite\_datareader.Read(); i++)
        {
                Row\[i\] = sqlite\_datareader;
        }
    

    and return the row. I tried passing the reader up by reference but that was unsuccessful My error: Bad array declarator: To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.

    .NET (Core and Framework) csharp php database help

  • c# forms (holy crap i'm not ready for this)
    U Uranium 235

    ok I get it, so I didn't even need cancel_click (this is a delegate, right?) at all since the DialogResult was already cancel in the form properties.

    .NET (Core and Framework) csharp php database 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