|
kenajelencres wrote: i followed a tutorial and added the ribbon interface i found in this site.
Which one? If you post a question on the forum at the bottom of the article, an email will be sent to the author of the article.
kenajelencres wrote: it can't add data in the .mdf file.
Is the .mdf file write protected? Did you update the connectionstring to reflect your current setup?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
tnx for the reply. the tutorial i found is from another site.
the .mdf is not write protected, i can add records using sql management studio. did you look at the project solution i uploaded? if yes, try to add a record and it will crash. here's the screenshot of the error:
error screenshot
pls help. i need to finish it asap.
|
|
|
|
|
I didn't, don't download "code" that often; most people will not download it, we don't know what's in there. You can post a snippet with the offending code here, including the full text of any exceptions you received.
kenajelencres wrote: pls help. i need to finish it asap.
That's why we usually have flexible deadlines. We're volunteers here, if you needed an answer sooner, you should have posted the question sooner.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
The problem is fairly well defined in that picture. You are trying to insert a duplicate key here; if you put a break point on the SubmitChanges line, take a look at the values in newGradeYear . I'm going to go out on a limb and suggest that your key value is in IDNo (take a look in your database and see if this field is the primary key).
|
|
|
|
|
first, i would like to thank everybody who replied. you really are helping a newbie. i hope one of these days i can become one of you so i can help others too.
yes, the IDNo is the primary key, but i'm not inserting a duplicate. when i add a record, it will add 1 to the last key. i have only one record in the mdf, with IDNo 1. when i add another, it will automatically become 2. the textbox is not enabled, so there's no way you can edit it. but when i clicked on the DONE button, i get that error.
it's really hard to learn programming.
googling for some answer, i found this:
This error typically happens when you are creating a new record in a MetaTable with a foreign key relationship and the foreign key record already exists.
what does that mean?
here's the screenshot of my dbml: dbml screenshot
|
|
|
|
|
Have you done as I suggested and put a breakpoint on SubmitChanges? If you don't know how, simply go to this line and press F9 (a red circle will appear). Do a debug build and then run your application using F5 (start with debugging). Let the application run to this point, and then look at the Locals window in Visual Studio; look for the value in IDNo - make sure it's 2. Let's rule that out first.
|
|
|
|
|
wow that was a nice tip. tnx.
i did what you said and it turns out that IDNo is 1 because at the beginning of my code is
maxIndex = gradeyear.Count() -1;
and because i have only one record which i inserted using SQL management studio, maxIndex value is 0. and at the create new record
newGradeYear.IDNo = newGradeYear.IDNo = maxIndex + 1;
the value of maxIndex is 1 which will result in a duplicate. what i did is i took the value of textbox which has the correct value by using int32.parse. a new error appeared at the database.SubmitChanges():
Cannot insert explicit value for identity column in table 'GradeYear' when IDENTITY_INSERT is set to OFF
any suggestion to fix this?
i wonder why it worked on the tutorial i followed and not on mine when it is almost exactly the same code. 
|
|
|
|
|
This is telling you that the field in the database is an identity column. That is a special type of column that you don't have to supply a value follow for. Simply drop the line where you give it a value and that should work.
|
|
|
|
|
I write as a relative novice but have the basics of namespace, class, method, etc. Looking to commence a mobile educational project. Looking for specific guidance on the creation of a mobile start page. Not yet ready to write lines of code out of
my head and so I need to get past the last hurdle. Looking for reading on best pracices and strategies for the creation of a good start page. In my request I would also hope
that this guidance includes links to what are known as snippets. Although I have seen many snippets in my readings I have yet to find a way to selectively search for what I need.
Initially, I would want the start page to allow to enter a name, grade level. Additionally, I would want an entry for a student area of academic difficulty. Getting these items into a start page would be a major advance. Presently
using C# in Visual Studio 2008 Team System but would hope to use Iphone and Android at some later time.
Much thanks as I await a reply
|
|
|
|
|
Try these[^] for size
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I need with this project as =RTD at excel can't trace back what the problem is at my C# code. I am fairly new at C# and working on a trading game application.
At excel I would like to use
1) =RTD("ProgramID",,"SecurityName","price")
2) =RTD("ProgramID",,"SecurityName","volume")
So at my program.cs file
class Program
{
static IDictionary<int, string>; ClientMappingDictionary = new Dictionary<int, string>();
static IList<string> ClientList = new List<string>();
static IDictionary<string, double> AUMDictionary = new Dictionary<string, double>();
static SecurityManager Sec = new SecurityManager();
static Orderbook_Generator OGen = new Orderbook_Generator();
static List<Security> A = Sec.SecGen();
[Guid("E128D214-56EF-4AA5-B5D6-7B2283CE2F79"), ProgId("TradeRTD.OrderRTD"), ComVisible(true)]
public class TradeRTD : MSExcel.IRtdServer
{
#region Data Members
private MSExcel.IRTDUpdateEvent m_callback = null;
private Timer m_timer = null;
private IDictionary<int, double> m_topics = new Dictionary<int, double>();
public IDictionary<string, Security> SecDic = Sec.SecurityMasterDictionary;
public List<string> Data = new List<string>();
#endregion
#region IRtdServer Interface
#region ServerStart
public int ServerStart(MSExcel.IRTDUpdateEvent CallbackObject)
{
m_callback = CallbackObject;
m_timer = new Timer(1000);
m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed);
m_timer.Start();
return 1;
}
#endregion
#region ServerTerminate
public void ServerTerminate()
{
if (null != m_timer)
{
m_timer.Stop();
m_timer.Dispose();
m_timer = null;
}
}
#endregion
#region ConnectData
public object ConnectData(int TopicID, ref Array Strings, ref bool GetNewValues)
{
Data = Strings.OfType<string>().ToList();
GetNewValues = true;
double price = SecDic[Data[0]].Price_History.Last();
double volume = SecDic[Data[0]].Volume_History.Last();
if (Data[1] == "price")
{
if (!m_topics.Keys.Contains(TopicID))
{ m_topics.Add(TopicID, price); }
else { m_topics.Add(TopicID, volume); }
}
return GetData(Data);
}
#endregion
#region DisconnectData
public void DisconnectData(int TopicID)
{
if (m_topics.Keys.Contains(TopicID))
{ m_topics.Remove(TopicID); }
}
#endregion
#region HealthCheck
public int Heartbeat() { return 1; }
#endregion
#region RefreshData
public Array RefreshData(ref int TopicCount)
{
object[,] data = new object[2, m_topics.Count];
int idx = 0;
foreach (string A in SecDic.Keys)
{
data[0, idx] = A;
data[1, idx] = SecDic[Data[0]].Price_History.Last();
++idx;
data[0, idx] = A;
data[1, idx] = SecDic[Data[0]].Volume_History.Last();
}
TopicCount = m_topics.Count;
m_timer.Start();
return data;
}
#endregion
#endregion
#region Supporting Methods
void m_timer_Elapsed(object sender, ElapsedEventArgs e)
{
if (null != m_callback)
{
m_timer.Stop();
m_callback.UpdateNotify();
}
}
private double GetData(List<string> junk)
{
if(junk[1] == "price")
return SecDic[junk[0]].Price_History.Last();
if (junk[1] == "volume")
return SecDic[junk[0]].Volume_History.Last();
else { return 0; }
}
#endregion
}
static void Main(string[] args)
{ .... orderbook generation and Server starting
I would really appreciate some help here as my =RTD is returning N/A all the time
Thanks
|
|
|
|
|
|
Kind of. Microsoft.Office.Interop.Excel provides a built in method for =RTD function of excel.
Where you can =RTD("ProgramID",servername,Topic_1,Topic_2,...) to access data
I was trying to use this. your link explains for static data. My data will be dynamic so I need to update constantly
modified 4-Sep-12 17:25pm.
|
|
|
|
|
yatici wrote: I was trying to use this. your link explains for static data. My data will be dynamic so I need to update constantly
That's quite an advanced topic for someone who "is new". Try the example here[^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
In a C# 2008 proxy class for a console application, I am thinking that I want to add code to the production application. I obtained some code from a contract shop that I want to work with. I want to be able to update the sql server 2008 database and change some directory path locations.
Am I allowing to do this in a proxy class? If so, are there certain rules I need to follow to be allowed to change the code?
If I am not allowed to change the code, can you tell me what my alternatitves are and how to code for these alternatives?
|
|
|
|
|
Are you and this[^] person one and the same or do you both work together?
|
|
|
|
|
I asked the other few programmers and one said the post was from them. Thus we work at the same company.
|
|
|
|
|
You two need to coordinate then. It's getting very confusing answering similar questions from different people.
|
|
|
|
|
There is a system needs to support 3 different protocol. Two protocols uses CGI to communicating, the other one uses self-define protocol base on the TCP protocol. The devices base on different protocols have different properties. So how to do the abstract architecture for this system. I find that it is difficult to design an abstract class to support these two protocol. Because there have a little similar. Does anyone meet the same problem? Or suggest other open source system support different network device?
|
|
|
|
|
First of all, you should ask this in the design forum instead. Secondly, if there's little similarity then don't try and shoe horn it into an abstract design.
|
|
|
|
|
I'm usually sticking to generalizing what they have in common into an interface (altough an abstract class might be preferred under some conditions), with a strategy-pattern to switch between actual implementations.
No, they needn't be 100% equal; sometimes one of the implementations has an extra property, or lacks one. If it lacks the property, we implement a dummy. The "extras" are usually put in a separate class that's embedded in the object, comparable to the composition-pattern.
Can you describe the three items roughly with it's most important members?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Two type device use the some CGI interface to control the device, so these two types have much similar, but the other should use the self-define protocol base on the TCP protocol. I consider one way to define a muster to include these three types command, and defines a muster of pages to show different pages to user by device type.. But I found that this way was too completed.
|
|
|
|
|
yu-jian wrote: so these two types have much similar, but the other should use the self-define protocol base on the TCP protocol.
I see.. two classes, who look very similar. And I see a third class, following the same design, implementing all the members that the other two classes have, but somehow ignoring their calls.
class MallardDuck: Duck
{
public void Quack()
{
System.Diagnostics.Debugger.WriteLine("Ku-wack");
}
}
class RubberDuck: Duck
{
public void Quack()
{
Console.WriteLine("Squeek");
}
}
class SomeDog: Politician
{
public void Quack()
{
}
}
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
yu-jian wrote: So how to do the abstract architecture for this system
Simple - you don't, because you haven't posted anything that suggests that there is any need to do that.
For something to be be abstracted (for the need to exist) there must be a specified need to use several things in a common way.
You do have two protocols that use a base protocol the same so those two together might use a helper class to facilitate processing. But that doesn't mean they implementating for each is represented as common entity.
|
|
|
|
|
I need to write a C# 2010 windows service that calls a console application at different times. Since I have not written a windows service before, can you tell me the following:
1. How do you setup a windows service initally? Is it a windows service a desktop application, console application, or what kind of an application is it?
2. How to you include a timer in the application so it executes at specified time periods?
Can you tell me and/or point me to references that will answer these questions listed above for me
|
|
|
|