|
By itself, Excel comes with a language Visual Basic , you can write your own programs called macros .
You can even record macros as you use Excel, the recorded macro is a Visual Basic program.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
public class AMCOMDB : DataContext
{
public Table<student> allStudents;
public Table<aClass> allClasses;
public AMCOMDB(string connection) : base(connection) { }
}
[Table(Name = "student")]
public class student
{
private string _studentName;
[Column(IsPrimaryKey =true,Storage ="_studentName")]
public string studentName
{
get
{
return this._studentName;
}
set
{
this._studentName = value;
}
}
private string _LARType;
[Column(Storage ="_LARType")]
public string LARType
{
get
{
return this._LARType;
}
set
{
this._LARType = value;
}
}
private string _studentType;
[Column(Storage = "_studentType")]
public string studentType
{
get
{
return this._studentType;
}
set
{
this._studentType = value;
}
}
private string _aviationLevel;
[Column(Storage = "_aviationLevel")]
public string aviationLevel
{
get
{
return this._aviationLevel;
}
set
{
this._aviationLevel = value;
}
}
private string _airDefenseLevel;
[Column(Storage = "_airDefenseLevel")]
public string airDefenseLevel
{
get
{
return this._airDefenseLevel;
}
set
{
this._airDefenseLevel = value;
}
}
private string _emergencyContact;
[Column(Storage = "_emergencyContact")]
public string emergencyContact
{
get
{
return this._emergencyContact;
}
set
{
this._emergencyContact = value;
}
}
[Table(Name = "grades")]
public class grades
{
private string _studentName;
[Column(IsPrimaryKey = true, Storage = "_studentName")]
public string studentName
{
get
{
return this._studentName;
}
set
{
this._studentName = value;
}
}
private int _ET;
[Column(Storage = "_ET")]
public int ET
{
get
{
return this._ET;
}
set
{
this._ET = value;
}
}
private int _CP;
[Column(Storage = "_CP")]
public int CP
{
get
{
return this._CP;
}
set
{
this._CP = value;
}
}
private int _SB;
[Column(Storage = "_SB")]
public int SB
{
get
{
return this._SB;
}
set
{
this._SB = value;
}
}
private int _EC;
[Column(Storage = "_EC")]
public int EC
{
get
{
return this._EC;
}
set
{
this._EC = value;
}
}
private int _finalGrade;
[Column(Storage = "_finalGrade")]
public int finalGrade
{
get
{
return this._finalGrade;
}
set
{
this._finalGrade = value;
}
}
[Table(Name = "classes")]
public class aClass
{
private string _classNumber;
[Column(IsPrimaryKey = true, Storage = "_classNumber")]
public string classNumber
{
get
{
return this._classNumber;
}
set
{
this._classNumber = value;
}
}
private string _courseSeries;
[Column(Storage = "_courseSeries")]
public string courseSeries
{
get
{
return this._courseSeries;
}
set
{
this._courseSeries = value;
}
}
private string _courseNumber;
[Column(Storage = "_courseNumber")]
public string courseNumber
{
get
{
return this._courseNumber;
}
set
{
this._courseNumber = value;
}
}
private string _distanceLearning;
[Column(Storage = "_distanceLearning")]
public string distanceLearning
{
get
{
return this._distanceLearning;
}
set
{
this._distanceLearning = value;
}
}
private string _classStartDate;
[Column(Storage = "_classStartDate")]
public string classStartDate
{
get
{
return this._classStartDate;
}
set
{
this._classStartDate = value;
}
}
private string _classEndDate;
[Column(Storage = "_classEndDate")]
public string classEndDate
{
get
{
return this._classEndDate;
}
set
{
this._classEndDate = value;
}
}
private string _primaryInstructor;
[Column(Storage = "_primaryInstructor")]
public string primaryInstructor
{
get
{
return this._primaryInstructor;
}
set
{
this._primaryInstructor = value;
}
}
private string _secondaryInstructor;
[Column(Storage = "_secondaryInstructor")]
public string secondaryInstructor
{
get
{
return this._secondaryInstructor;
}
set
{
this._secondaryInstructor = value;
}
}
private string _location;
[Column(Storage = "_location")]
public string location
{
get
{
return this._location;
}
set
{
this._location = value;
}
}
private string _TDYCosts;
[Column(Storage = "_TDYCosts")]
public string TDYCosts
{
get
{
return this._TDYCosts;
}
set
{
this._TDYCosts = value;
}
}
private string _studentCount;
[Column(Storage = "_studentCount")]
public string studentCount
{
get
{
return this._studentCount;
}
set
{
this._studentCount = value;
}
}
private List<grades> _classGrades;
[Column(Storage = "_classGrades")]
public List<grades> classGrades
{
get
{
return this._classGrades;
}
set
{
this._classGrades = value;
}
}
As you can see I have 3 classes under 1 database file. The problem I am having is that when I try to pull data using:
AMCOMDB ADB = new AMCOMDB(connectionString);
if (ADB.DatabaseExists())
{
var stud = ADB.GetTable<student>();
var clas = ADB.GetTable<aClass>();
IQueryable<string> query = from c in stud
where c.studentName.Length > 5
orderby c.studentName.Length
select c.studentName.ToUpper();
foreach (string name in query)
{
}
}
I get this at the foreach statement:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Invalid object name 'student'.
I have tried to change everything and I even tried to create 3 database files but the error still comes up. I don't know what I am doing wrong. Any help is appreciated.
modified 1-Jul-16 15:28pm.
|
|
|
|
|
The results of the query can be "null"; you need to check your "query" variable for null (and also pick a more descriptive / less confusing variable name).
|
|
|
|
|
Hi, I'm using a property as byte array in a model. Now while serializing this model into xml, if this property is null, then it's not rendering as tag. I'm using [XmlElement(IsNullable=true)] attribute on that property.If i do this, in this case it's creating tag with attribute something like xi:nil=true. I don't want this. If that property is null, then make it as empty element else assign value.
Please give me solution.
|
|
|
|
|
Why do you care what the XML looks like?
Supply a default constructor for the class in question with an initializer for the byte array to resolve any nulls when de-serializing.
|
|
|
|
|
The other party app receiving XML without any attributes. If any attributes are there that throwing exception
|
|
|
|
|
Then use the error handler of the serializer to do a fix-up.
Or tell the receiving app to fix their class constructor.
You don't like your options? Life is hard and you die.
|
|
|
|
|
Hi all,
I am trying to make a program that locks the computer every 1 hour, and display a window to the user, this should have a question , and textbox to answer the question.
I don't how to do this exactly, i tried to make a code to change the password of the user to be the answer of some question and the password hint to be the question, but i failed.
I don't know if this method works or not, if you can help me to do this, then i am grateful
However, if you know any other techniques to do this, please suggest
|
|
|
|
|
You're trying to do what?!??? Seriously, why are you trying to do this?
This space for rent
|
|
|
|
|
I think you know the answer to your question.
|
|
|
|
|
It has to be asked. There's a one in 10 billion chance it might be legit.
This space for rent
|
|
|
|
|
Yep, and the population of the planet is somewhat less than ten billion....
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
|
Was your hour up when you were writing that post?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
You create your own desktop[^], and set it to the foreground. Next you run your GUI in that Desktop, and close the desktop again if the requirements are met.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I am doing this in my own computer, and i will make a copy of this application on my children's PC, the purpose of this software is to encourage them to gain knowledge.
The main problem, is that i don't know how to make my program on top of everything , and make the user unable to get rid of it , until solving the question
|
|
|
|
|
Your program can't be on top of everything, unless it is running as a screensaver. Other applications will fight for the right of being the topmost.
The login-screen and the desktop are "desktop" objects, capable of showing applications. You'd need to create one (example here[^]) and then run your application in that new desktop. There's bound to be an article on CodeProject that shows "desktop switching", which would be a good place to start*
No, not easy if you're new to .NET.
--edit
*) Found it; Desktop Switching[^]. Contains a desktop-class that hides the complicated stuff.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
In my project, there is a folder called "Resources" and there is an Excel file called "query.xlsx" inside that folder.
I try to load Excel file like this :
ExcelFile ef = ExcelFile.Load(HttpContext.Current.Server.MapPath("~/Resources/query.xlsx"));
And I get this exception :
HttpContext.Current.Server = 'HttpContext.Current.Server' threw an exception of type 'System.NullReferenceException'
How can I load that Excel file properly? Thanks.
|
|
|
|
|
MapPath is only used with websites: it "communicates" with IIS and converts "~" into the root folder fro your site.
For non-website based applications the HttpContext and the Server don't exist, so you get a null reference.
If the file changes at all, then consider storing it elsewhere: Where should I store my data?[^] will help.
If it doesn't change at all, then embed it as a resource to your application, and use Properties.Resources to fetch the file data.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I want to ping a list of IPs but it's not working.
I already use this function in console app and it was working.
<pre>string[] addresses = { "192.168.1.2", "192.168.1.3", "192.168.1.4" };
void show()
{
List<Task<PingReply>> pingTasks = new List<Task<PingReply>>();
foreach (var address in addresses)
{
pingTasks.Add(PingAsync(address));
}
Task.WaitAll(pingTasks.ToArray());
int i = 0;
listView1.Clear();
listView1.Columns.Add("Device IP", 100);
listView1.Columns.Add("ping", 60);
foreach (var pingTask in pingTasks)
{
string[] A = { addresses[i], pingTask.Result.RoundtripTime.ToString() };
ListViewItem item = new ListViewItem(A);
listView1.Items.Add(item);
}
}
Task<PingReply> PingAsync(string address)
{
var tcs = new TaskCompletionSource<PingReply>();
Ping ping = new Ping();
ping.PingCompleted += (obj, sender) =>
{
tcs.SetResult(sender.Reply);
};
ping.SendAsync(address, new object());
return tcs.Task;
}
please helpppppppppp!
|
|
|
|
|
Don't post in multiple places - it duplicates work and that annoys people.
You already have this in QA, so leave it there!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi folks, looking for some help here, I need to make a Rest request.
I'm using Microsoft studio 2015.
I need to include header i.e Content-type: application/json and pass in 2 parameters.
Any pointer or help much appreciated.
|
|
|
|
|
|
I'm working on dataGrid Save content based on SQL Server data, C # smart devices and I have all the code I do not make mistake but not save data
string partDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
string partBD = System.IO.Path.Combine(partDir, "embarque.sdf");
string connectionstring = string.Format(@"DataSource={0}; Password ='root'", partBD);
try
{
using (SqlCeConnection con = new SqlCeConnection(connectionstring))
{
string ConsultaSQL = "INSERT INTO ENVIO VALUES(@RAID, @NPARTE, @CANTIDAD, @VENTANA, @LIDER, @FECHA)";
foreach (DataRow row in dt.Rows)
{
SqlCeCommand cmd = new SqlCeCommand(ConsultaSQL, con);
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@RAID", Convert.ToString(row["Raid"].ToString()));
cmd.Parameters.AddWithValue("@NPARTE", Convert.ToString(row["Nparte"].ToString()));
cmd.Parameters.AddWithValue("@CANTIDAD", Convert.ToString(row["Cantidad"].ToString()));
cmd.Parameters.AddWithValue("@VENTANA", Convert.ToString(row["Ventana"].ToString()));
cmd.Parameters.AddWithValue("@LIDER", Convert.ToString(row["Lider"].ToString()));
cmd.Parameters.AddWithValue("@FECHA", Convert.ToString(row["Fecha"].ToString()));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
MessageBox.Show("Datos Agregados");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
|
|
|
|