|
I have to be able to insert max size string rather 1000 length string
|
|
|
|
|
simpledeveloper wrote: in committing it on Git or over written by the remote branch
If you've got multiple developers generating migrations at the same time, things can get very confused. Especially if you're all using the same development database instance.
Code First Migrations in Team Environments - EF6 | Microsoft Docs[^]
simpledeveloper wrote: Even though I made it EventComment 1000 in Database then deleted my migration file - then ran the add migration
As explained in the article above, Add-Migration doesn't look at the database; it looks at the model snapshot stored with the last migration. Manually changing the database won't cause EF to generate a migration to change it back.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Can you please help me what can I do now - yes it seems that it is storing in snapshot - how can I clean it up - I am feeling very discomfort in changing things as it stored in snapshot and any mistake like the one above it happened because of merging - it made it very difficult - any help please. Can you please suggest me something please - thank you.
|
|
|
|
|
|
Hi Richard - how can I freshly generate add migration because its not creating me the same again. So I want to generate the migration file again how can I? The file is gone I am not looking for it - merging links help me but for future to be careful. Now I want to regenerate the migration files with the code what can I do? Its not allowing me. Please need help.
|
|
|
|
|
|
Again thank you Richard my friend - thanks a lot
|
|
|
|
|
It was so simple in VB, accessing other forms properties.
The main form, right after it's drawn, I want to check for a .db file and if it dosen't exist, to make visible a form (already defined) to create it the db file. (form already as always-on-top, but not visible).
After a ton of internet research, i'm still where I started. Closest I got gave me a threading error, which I've learned to work around in VB, but this, is just confusing (TechTracker.CreateDB.ActiveForm.Visible = true;)
I like how much c# is to PHP AFA structure, loops, arrays, strings. But this stuff is confusing me
|
|
|
|
|
Uranium-235 wrote: It was so simple in VB, accessing other forms properties. The same is true in C#. Perhaps you could show your code and explain exactly where the problem lies.
|
|
|
|
|
my main.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using System.IO;
namespace TechTracker
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void Main_Load(object sender, EventArgs e)
{
if(!File.Exists(Directory.GetCurrentDirectory() + "\\Tracker.db"))
{
}
}
}
}
createDB.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TechTracker
{
public partial class CreateDB : Form
{
public CreateDB()
{
InitializeComponent();
}
}
}
both were made as windows forms designer. createDB is not visible by default. As you can see, if the file is not there, they choose to create it as an sqlLite (I know I still have to define it in using in createdb) database. createDB is topmost enabled and won't let the main form be accessible when it's up. That logic shouldn't be hard, i've done it with vb before. I'll later get a better method of detecting the database file (store filepath in registry, or local file). Probably even allow switching DB files in a settings dropdown. For now, this just basic code to get some of the basic functionality out of this way.
I learned VB.net from scratch using only google on trial and error. Got fairly good at it too. It's just these individual methods of c# I need to get out of the way
oh and yes, it's me from the previous post. I decided to go with sqllite instead of mysql or transactional HTTP transfer. I'm making this mainly for me for the time being, and I can just use google drive or something to sync the sqllite db file for housecall (on my laptop) or home use
thank you
|
|
|
|
|
Forms are nothing but classes. So how do you create an instance of a class? You "new one up".
CreateDB createForm = new CreateDB();
createForm.ShowDialog();
This would be the exact same thing you do in VB.NET.
|
|
|
|
|
I remember in VB.net I would use something like My.Forms but it's been a while
|
|
|
|
|
That is actually a wrapper around exactly what I posted. What you're calling "in VB.NET" is actually just a bunch of classes in a namespace that wrap this kind of functionality to maintain "backward compatibility" with older VB code.
The wrappers and extensions are not in the language itself, but is in a library of classes. Since it's all in a .NET library, you could even use the library in other languages, like C#, but I wouldn't recommend doing that. What the library does is insulate you from learning and knowing all the gritty details of how things should be done and they actually work.
|
|
|
|
|
Uranium-235 wrote: createDB is topmost enabled and won't let the main form be accessible when it's up. You don't need Topmost, just make it a dialog so it automatically disables the calling form:
CreateDB dbCreator = new CreateDB();
DialogResult rc = dbCreator.ShowDialog();
Here is a really useful C# tutorial: http://www.charlespetzold.com/dotnet/index.html[^].
|
|
|
|
|
Thank you guys. I was googling for over an hour last night (phrasing?). I still have a lot to learn.
|
|
|
|
|
You will never learn programming from Google or Youtube. Get yourself a decent book that will teach you properly, starting with the basics. Time spent now will pay dividends in the future.
|
|
|
|
|
I learned PHP and VB from googling. Actually I learned PHP because a game named Tribes used the zend engine and I picked up a PHP book and realized I knew the syntax better than the book. Did PHP for 10 years and made some pretty impressive stuff.
I also did some stuff in VB that was pretty advanced. But I haven't done it in a few years (like, 4?)
Once you learn many of the basics of .net, all I have left is translating it into the syntax of c#, which IMO has better structure than VB, and a structure i'm more familiar with (logic and conditions like PHP, some variables like C++, which I took in high school)
I don't think I could relearn the VB crap. I'm used to &&, ||, if() foreach loops, all in PHP. One thing I didn't like is you can't do multiple logical comparisons in switch/case, but that it rarely used in PHP
|
|
|
|
|
actually this is throwing me an error. "Quote: Cannot implicitly convert type 'void' to 'System.Windows.Forms.DialogResult
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void Main_Load(object sender, EventArgs e)
{
if(!File.Exists(Directory.GetCurrentDirectory() + "\\Tracker.db"))
{
this.Enabled = false;
CreateDB dbForm = new CreateDB();
DialogResult res = dbForm.ShowDialog();
if (res == DialogResult.Cancel)
Application.Exit();
}
}
}
public partial class CreateDB : Form
{
public event EventHandler CancelPressed;
public CreateDB()
{
InitializeComponent();
}
private void Cancel_Click(object sender, EventArgs e)
{
if (CancelPressed != null)
CancelPressed(this, EventArgs.Empty);
}
}
|
|
|
|
|
|
private void Cancel_Click(object sender, EventArgs e)
{
return DialogResult.Cancel;
}
I returned a DialogResult now I get
Since 'TechTracker.CreateDB.Cancel_Click(object, System.EventArgs)' returns void, a return keyword must not be followed by an object expression
and yeah I tried changing void to DialogResult and it gave me an error on the form
|
|
|
|
|
|
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.
|
|
|
|
|
|
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[];
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.
|
|
|
|
|
oh duh I needed to specify 'Array'
but now I get
Array SQLLiteReader Row[];
^^^
"; expected"
^
identifier expected
|
|
|
|