|
can i program an application to generate dll file as an output ,for example:
program generate the following code :
class cars
{
private string _Model;
Private string _Type;
public Cars()
{
}
public string Model
{
get{return _Model;}
set{_Model=Value;}
}
public string Model
{
get{return _Model;}
set{_Model=Value;}
}
}
I need to convert the above code to a dll(Cars.dll) file that simply can use it:
Please help me to do it,
Thank you very much,
|
|
|
|
|
Yes you can. When creating a new project choose windows class library.
|
|
|
|
|
I don't need to create it Manually I want do it Programmatically Can I do it,
|
|
|
|
|
|
|
Have a look at http://www.codeproject.com/csharp/codecompilation.asp
Hope this helps...
|
|
|
|
|
thank you so much
But I have another problem
how can I set the assemply info(Properties Folder) for the Source Code or the Dll output file
Best Regards ,
|
|
|
|
|
What do you mean with assembly info(Properties Folder)?
Can you explain it clearly so that I can try help you ?
|
|
|
|
|
give me about outerxml concepts
|
|
|
|
|
The outerxml property contains the xml markup for the element including it's children.
---
single minded; short sighted; long gone;
|
|
|
|
|
what are the uses of outerxml
and also how to use....
|
|
|
|
|
I am thinking about expressing the my business Rules using c# 3.0 Extension
Methods on a datacontext that is generated by LinQ to Sql code generator.
the thing is I am worried about the "block box approach" for my system
incase ı do misuse the "new staff".Even though I see it as more
declerative than imperative,still I have doubts....
ok.We have a site that has frequent deployment needs,we do not use dlls other
than the framework and the customdll's for special web UI data controls.We
wanna be much more agile(faster) using new staff in c# and .net future
releases.
Our biggest problem is with the typed-datasets is we have is that >>>We
have to test all the Userinterfaces that depends on to that typedDataset if
we have to deploy my datasets.Even non related items need to be checked as we
are building as a team many people do changes all the time on the source
code.
looking from this side to LinQ to SQL everything is fine (if u are not
changing the database schema).
But the thing is if I am getting first class objects with LinQ to SQL and
thinking about adding behavior more than CRUD that is already defined in
DLinQ.
But I am not sure how much I will couple my self with the extension methods(I
see it as a pratical way to implement visitor design pattern ...is it?)
..ok...at the end of the day , I have come up with 3 cases ...
I have a change request on a page,and the team has changed mnay pages without
my knowledge and I need to deploy quick.
CASE 1 > I need more data from database....."that is fine" I just code
behind userinterface,sql is generated at runtime.....really cool
CASE 2 > my business logic changed , I have implemented on the extension
method ....>test all the UI that uses the business logic
>infact much better than
datasets as nonrelated items are not checked.
CASE 3 > Db schema change......check everything!(dataset/DlinQ.....nobody can
help even the "silverbullets") > at least better type system and
intellisense support.
but I need more cases, especially I need horror scenerios on factors that
will negatively affect on deployment time.
thanks
|
|
|
|
|
Hello there,
I have a task to save Videos (mpg or others) to database .. I'm using Access 2003 .. I could save photos to database but not videos.
Asaad
|
|
|
|
|
If you're using videos then the stored objects are probably going to be pretty large. Not sure if Access can handle large objects though. I use Postgres and this is the way I do it :
<br />
String strMovName;<br />
strMovName = dlgFile.FileName;<br />
NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=secret;Database=db;");<br />
<br />
FileInfo TheFileName = new FileInfo(strMovName);<br />
conn.Open();<br />
NpgsqlCommand command = new NpgsqlCommand("INSERT INTO resources (object) VALUES (lo_import('C:/Program Files/Movies/" + TheFileName.Name + "'))", conn);<br />
command.ExecuteNonQuery();<br />
conn.Close();<br />
In this particular example, my movies and pics are stored in a fixed location ( C:/Program Files/Movies/ ) so I hardcoded the path. If you want the path as a variable as well, you have to play around with the query. I also created a table called object, which is of either the OID / bytea type. You can use this code in virtually any db that use SQL queries.
Hope this helped. 
|
|
|
|
|
Thank you Rick .
Your Method stores the Path of the file but i want a way to store the video as object so i don't need to the original file anymore .. i could store photos itself in the database (not only pathes) but i'm trying with the videos.
Thank you again.
|
|
|
|
|
Hi I'm 'trying to get a textfield focused after a message has been given to the user.
This was pretty easy to do in other forms, but in this specific it doensn't focus. After the system has finished validating it should save the entered data to a database and clear the textfields for new entry ( which it does). But when validating it gets an exception, after clicking on ok in the messagebox it doesn't focus, but it clear all the textboxes. And thus, it's skipping to the clearing code.
Hereby I send my code so you guys could take a look. Please HELP!!!
By the way, the reason why I chose to use separate if statements for each "row of fields" is because the user is not obligated to fill in ALL row of fields. It may occur that he enters only row 1, 2 and 3. HEELLLLPPPP!!!
if (txtBrnchNr_1.Text.Trim().Length > 0 && txtBrnchDescr_1.Text.Trim().Length > 0 && txtBkBrnch_1.Text.Trim().Length > 0)
{
if (rdbBckOff_1.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}
if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_1.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_1.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_1.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_1.Text.Trim(), txtBrnchDescr_1.Text.Trim(), bckOff, txtBkBrnch_1.Text.Trim()));
this.isOkToSave = true;
}
}
//Same procedure for 2nd row of fields
if (txtBrnchNr_2.Text.Trim().Length > 0 && txtBrnchDescr_2.Text.Trim().Length > 0 && txtBkBrnch_2.Text.Trim().Length > 0)
{
if (rdbBckOff_2.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}
if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_2.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_2.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_2.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_2.Text.Trim(), txtBrnchDescr_2.Text.Trim(), bckOff, txtBkBrnch_2.Text.Trim()));
this.isOkToSave = true;
}
}
//Same procedure for 3rd row of fields
if (txtBrnchNr_3.Text.Trim().Length > 0 && txtBrnchDescr_3.Text.Trim().Length > 0 && txtBkBrnch_3.Text.Trim().Length > 0)
{
if (rdbBckOff_3.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}
if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_3.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_3.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_3.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_3.Text.Trim(), txtBrnchDescr_3.Text.Trim(), bckOff, txtBkBrnch_3.Text.Trim()));
this.isOkToSave = true;
}
}
//Same procedure for 4th row of fields
if (txtBrnchNr_4.Text.Trim().Length > 0 && txtBrnchDescr_4.Text.Trim().Length > 0 && txtBkBrnch_4.Text.Trim().Length > 0)
{
if (rdbBckOff_4.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}
if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_4.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_4.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_4.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_4.Text.Trim(), txtBrnchDescr_4.Text.Trim(), bckOff, txtBkBrnch_4.Text.Trim()));
this.isOkToSave = true;
}
}
//Same procedure for 5th row of fields
if (txtBrnchNr_5.Text.Trim().Length > 0 && txtBrnchDescr_5.Text.Trim().Length > 0 && txtBkBrnch_5.Text.Trim().Length > 0)
{
if (rdbBckOff_5.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}
if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_5.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_5.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_5.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_5.Text.Trim(), txtBrnchDescr_5.Text.Trim(), bckOff, txtBkBrnch_5.Text.Trim()));
this.isOkToSave = true;
}
}
//Same procedure for 6th row of fields
if (txtBrnchNr_6.Text.Trim().Length > 0 && txtBrnchDescr_6.Text.Trim().Length > 0 && txtBkBrnch_6.Text.Trim().Length > 0)
{
if (rdbBckOff_6.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}
if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_6.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_6.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_6.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_6.Text.Trim(), txtBrnchDescr_6.Text.Trim(), bckOff, txtBkBrnch_6.Text.Trim()));
this.isOkToSave = true;
}
}
// Everything OK to save to database
}
DataSet dsBranch = new DataSet();
clsAlchCustomMeth.CreateSelCmd("SELECT * FROM SPRBRH00P;");
clsAlchCustomMeth.myAdapter.Fill(dsBranch, "Branches");
foreach (clsBranchGeneric b in myBranches)
{
DataRow newRow = dsBranch.Tables["Branches"].NewRow();
newRow["BRHBRANCH"] = b.BranchNr;
newRow["BRHBRHDES"] = b.Description;
newRow["BRHBCKOFF"] = b.BackOffice;
newRow["BRHBRHBOK"] = b.BookBranch;
dsBranch.Tables["Branches"].Rows.Add(newRow);
clsAlchCustomMeth.CreateInsCmd("INSERT INTO SPRBRH00P (BRHBRANCH, BRHBRHDES, BRHBCKOFF," +
" BRHBRHBOK) VALUES (@Brh, @BrhDes, @BckOff, @BrhBok);");
clsAlchCustomMeth.myAdapter.InsertCommand.Parameters.Add("@Brh", OleDbType.VarChar, 3, "BRHBRANCH");
clsAlchCustomMeth.myAdapter.InsertCommand.Parameters.Add("@BrhDes", OleDbType.VarChar, 35, "BRHBRHDES");
clsAlchCustomMeth.myAdapter.InsertCommand.Parameters.Add("@BckOff", OleDbType.VarChar, 1, "BRHBCKOFF");
clsAlchCustomMeth.myAdapter.InsertCommand.Parameters.Add("@BrhBok", OleDbType.VarChar, 3, "BRHBRHBOK");
try
{
clsAlchCustomMeth.myAdapter.Update(dsBranch, "Branches");
dsBranch.AcceptChanges();
changesOK = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
if (changesOK == true)
{
changesOK = false;
this.ClearForSaveAndNew();
}
}
Poppsie
|
|
|
|
|
Farica wrote: # Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Read "How to get and answer to your question" at the top. Pay particular note to items 4 and 5.
|
|
|
|
|
If you think anyone will bother reading through a 6-feet post then good luck!!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I would like to help you if I could understand what you needed, sorry.
You should better explain in details what you need, give example, screenshot...etc
This way, it is really hard. Also, what is this exception thrown after validation is finished?
This may be a clue in finding a solution to your question.
|
|
|
|
|
Hello!
Can anyone help me in the following scenario:
- We need to insert multple comma notations in a string (25 in total), at a predefined index number.
- Currently we are 25 inserts as below:
line = line.Insert(7, ",");
line = line.Insert(15, ",");
line = line.Insert(37, ",");
- Is there any better way of doing that!!!?
Thanks in advance!
Adeel
--
|
|
|
|
|
string comma = ",";
int[] insertIndexes[25] = {7,15,37,...};
for(int i =0;i < insertIndexes.Length;i++)
{
line = line.insert(insertIndexes[i],comma);
}
|
|
|
|
|
! actually i was curious if there is any replacement for insert!!! !
|
|
|
|
|
Each line = line.Insert(7, ","); will create a new string and copy all its characters.
If that results in several hundred chars being copied overall, I recommend you use
a StringBuilder, with sufficient initial capacity.
Then set up the logic to copy part of the input, add a comma, copy next part, etc
using nested for loops, and/or an array of constants.
finally transform StringBuilder object back to string with ToString().
|
|
|
|
|
const int[] predefinedIndexes = new int[] {7, 15, 37};
const string notation = ",";
int lineLength = line.Length.
foreach(int index in predefinedIndexes)
{
// just for your safety
if(index < 0 || index >= lineLength)
continue;
line.Insert(index, notation);
}
Hope this helps...
|
|
|
|
|
You could try the following code:
private string insertChars(string str, char insertChar, int[] insertIndexes)
{
StringBuilder b = new StringBuilder(str.Length + insertIndexes.Length);
int count = 0;
for (int i = 0; i != str.Length;i++)
{
if (i == insertIndexes[count])
{
b.Append(insertChar);
if (++count==insertIndexes.Length)
{
b.Append(str.Substring(i,str.Length-i));
break;
}
}
b.Append(str[i]);
}
return b.ToString();
}
For it to work, your index array must be sorted.
|
|
|
|
|