Hi All,
I am using Visual Studio 2010. How to Insert,Update And Delete Datagridview using Entity Framework in C#.net
Hi All,
I am using Visual Studio 2010. How to Insert,Update And Delete Datagridview using Entity Framework in C#.net
Hello,
i have a visual Basic collection which is the result of a query, but i can not get the data from this collection, i tried this little test
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.VisualBasic; namespace testCollection { class Program { static void Main(string[] args) { Microsoft.VisualBasic.Collection persons = new Collection() { new Person{Age=12, Name="Alain", Profession="Prof"}, new Person{Age=31, Name="Kati", Profession="Spor"}, new Person{Age=23, Name="Mari", Profession="Bak"}, }; foreach (Person item in persons) { Console.WriteLine("Name:{0}, *** Age:{1}, *** Profession:{2}",item.Name, item.Age, item.Profession); } Console.ReadKey(); } } }
and it works, i tried to compare it with my data collection with the help of debug: in this project:
in my project i have this:
and also i have an error message:
the ParameterChoice is a class created to store the data from the collection into a list that i will use to binder an DataGrid in WPF application,
class ParametersChoice { public string ParameterName { get; set; } public string Opeartion { get; set; } public string Step { get; set; } private bool _selected; public bool Selected { get { return _selected; } set { _selected = false; } } }
thanks for your help.
Regards
Alex
Hello,
INTRO
I'm a total noob in C#. Literally know nothing. I haven't programmed anything since Actionscript 5.0 and Javascript 2.0. I always enjoyed it, but never kept up with it.
Anyways, my current job (completely unrelated to programming of any kind) has a a pain in the butt task that I would like to build some type of program to assist with, and I'm wondering if C# is capable of doing what I want.
I'm not asking anyone to write the program, or give me any guidance. It's just I'd like to know if what I need is even possible before taking on the burden of learning the language.
ACTUAL QUESTION
The task that I mentioned above is entering information into a program my company uses. This information is entered into 5 different text boxes. A significant time of my day is spent entering the exact same information into these boxes for several different projects, and it involves switching from keyboard to mouse often, which is a huge time waster and prevents me from getting into any kind of flow.
What I'd like to be able to do, is build a super simple program where I could enter this information once, copy the data from those text boxes, and then paste the info into the other program with one keyboard command or button press. This would require tabbing after each data set to get into the next box.
So I'm thinking copy the values from text boxes, and input them into a string. In between each set of information gathered from each of the 5 text boxes, the program would have to "tab" to the next box. Is it even possible to input a "tab" command in the middle of the string?
I know that doesn't exactly make sense. I'm thinking of having the program enter the following keyboard strokes based off of data entered into the text boxes in the program I want to build: "5""4""5""0""6""9""4""TAB""F""9""3""6""TAB""A""TAB""T""0""6""7""8""1""1'"TAB""1""0""0"
Again, I'm not asking for someone to write this for me, or even tell me how it would need to be built. I just want to know if it's possible (and as simple as I think) before investing the time in learning and money in text books. I would plan to build this through Visual Studio.
Hi. I am relatively new to c# and am looking for a coding pattern that .net folks would find acceptable for implementing the following:
After being passed an application id, decide which class/method to call based on a lookup entry in a sql table.
The lookup to the table isn't really the question here. I know how to do that. It has more to do with how a class/method name can be used in c# dynamically if its name is determined only after the lookup is complete.
The params passed to the method would always be the same regardless of which method is called. I would even be ok using the same method name always but would at least like to determine the class (ie object) name dynamically.
Currently, our prototype calls only one method as follows:
ProcessX X = new ProcessX(); X.ProcessWorkflow(m, e);
I am loading pdf into System.Windows.Forms.WebBrowser in c# windows application using below code. On the first time load the pdf is loaded without any problems but when I call this on button click event for second time with "#page=2" parameter I see a dark grey area and no pdf.
What I want is that when the button is clicked WebBrowser control should navigate to page 2 of the document.
private System.Windows.Forms.WebBrowser ctlwebBrow1 = new System.Windows.Forms.WebBrowser(); pdfPath=@"D:\\Projects\\ProjectDialog\\bin\\Debug\\Form_GENERAL_datafilled.pdf" ctlwebBrow1.Navigate("about:blank"); if (ctlwebBrow1.Document != null) ctlwebBrow1.Document.Write(string.Empty); ctlwebBrow1.DocumentText = "<html></html>"; //ctlwebBrow1.Navigate(pdfPath); // THIS WORKS FINE AND LOADS THE PDF ctlwebBrow1.Navigate(pdfPath + "#page=3");// THIS IS NOT WORKING, GREY AREA SHOWN INSTED OF PDF ctlwebBrow1.Dock = DockStyle.Fill;
Thanks & Regards
Sumit
I do not have any C# experience but I am trying to accomplish the following: I would like to read data from my interface and implement it on the "Horse" class, I have used words like "Animals" and "Horse" purely for this example
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Processing.aspx.cs" Inherits="Horse" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>Edit Horse Page</title></head><body><form id="form1" runat="server"><div><table><tr><td>Name</td><td><input type="text" name="Name" /></td></tr><tr><td>Age</td><td><input type="text" name="Age" /></td></tr></table><input type="submit" value="Submit" /></div></form></body></html>
code behind:
public Class Horse : Animals { // we are overriding the DoAge method because Horses age has double effect override void DoAge() { // the effect of age is double compared to Animals class this.age +=2; } }
I would also like to create a Generic Class that can read from the Database and Implement this on Horse
I have a connection string in my config file
Thank you in advance
It appears that when using async, every async function called must have a call to another async function which is, in turn, called with the await statement. If an async function does not have an await call to another async function, an error is generated. How does one end this seemingly endless async, await sequence?
Update: I am using AsyncBridge - Async Support for .NET 3.5 (NuGet package).
rwb
Many Thanks & Best Regards, Hua Min
I have some classes that use settings from the configuration file that are access using the System.Configuration.ConfigurationManager.AppSettings["Param1"]. I'm trying to use these classes in a console app where I can opening up the ????.Exe.Config file but the Classes are not seeing the parameters in the System.Configuration.ConfigurationManager.AppSettings["Param1"].
What am I not doing for the Classes not to see the retrieved parameters?
public static bool LoadConfiguration() { fileMap.ExeConfigFilename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "????.Exe.Config"); if (!File.Exists(fileMap.ExeConfigFilename)) { return false; } config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); section = (AppSettingsSection)config.GetSection("appSettings"); ConnectionStringsSection currConn = GetConnectionStringfromConfigFile(); return true; }
chuck
Hi All,
Firstly I'd like to begin with that I'm relatively new to C# but have been familiar with the application for many years but never really taken on a project.
I am attempting to make a database for my work where we have a database with a list of patients and doctors which we then use to mark off each time the patient comes in for tests after 6 visits the patients database is used to pull names, addresses etc of patients that need updated request forms and then they are printed on the form and sent to the doctor for renewal. The database also prints doctors names and address on request forms and are printed in mass and given to them to hand to patients.
Anyway, the administrator handed me her latest database which was created in Microsoft Access, I have created a project and imported the database and linked it with the forms. I am able to see the list of patients and doctors on my form however when I try
and add a new one and save it, it saves while I have the form open but when I close it and re-open it won't be there. Similarly I added new fields to the 'patients' database and anything I type there is not saved at all where as the original information will
remain for the time that the program is running but does not exist beyond this point. Hopefully this rant makes sense. I did some research in advance and tried this code but it hasn't worked for me at all. EDIT: I've just had another look at the program and
any information I enter is saved to the database but only for the OLD fields, the new fields I added to the patients table do not save in the database and I have no idea why, I generated these fields in the table using the Dataset designer would I need to
return to Access to add these tables then reinsert my database as it's possible that visual studio is not adding these new fields to the original database?
namespace Pathology_West_Database { public partial class frmPatient : Form { public frmPatient() { InitializeComponent(); } private void frmPatient_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the '_New__DrsReqForms_2k_2013_03_15DataSet.tblPts' table. You can move, or remove it, as needed. this.tblPtsTableAdapter.Fill(this._New__DrsReqForms_2k_2013_03_15DataSet.tblPts); // Resize the column once, but allow the users to change it this.tblPtsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } // Tracks for PositionChanged event last row private DataRow LastDataRow = null; // Checks if there is a row with changes and writes it to the database private void UpdateRowToDatabase() { if (LastDataRow != null) { if (LastDataRow.RowState == DataRowState.Modified) { tblPtsTableAdapter.Update(LastDataRow); } } } private void tblPtsBindingSource_PositionChanged(object sender, EventArgs e) { // If a user moves to a new row, check if the last row was changed BindingSource thisBindingSource = (BindingSource)sender; DataRow ThisDataRow = ((DataRowView)thisBindingSource.Current).Row; if (ThisDataRow == LastDataRow) { throw new ApplicationException("It seems the" + " PositionChanged event was fired twice for " + " the same row "); } UpdateRowToDatabase(); LastDataRow = ThisDataRow; } private void frmPatient_FormClosed(object sender, FormClosedEventArgs e) { UpdateRowToDatabase(); }
Also wondering if it's possible to use a printing tab on a form to pull the information from the database into a form and then print in mass as explained above, previously this was all done in a basic 'crappy' form in Microsoft Access which I am attempting to redesign and add more features so it's easier to use. Would this be something that needs to be opened in Microsoft Access to process or can such things be done in Visual Studio?
Thanks in advance for your replies!
Hi Guys I have Employee Table have 10 employee i need any edit in any employee in Employee table
registering in database in another table EmployeeHistory table
Example
EmployeeID 10
EmployeeName adil
Nationality german
Job Engineer
suppose i changed Naionality from german to italian
registering this changed in another table EmployeeHistory table
How to register only changing in record in another table
what codition i write to take only difference in another table
I need to do that to know what changes ahppen in database every day
please help me
Dear All,
The code below works fine in all PC's except one PC where after writing all data the excel file is just getting closed automatically and disappearing. I am using Windows 7 as the OS. can anybody help why this is occuring
Thanks in advance
using System;itismeiqbal
Hello
I have 3 columns in my Query (ACCESS Query).
I have 3 columns in .xsd.
But I see just 2 columns in .xml.
The first column has data.
The second column does not have data (I want that it was empty).
The third column has data.
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:od="urn:schemas-microsoft-com:officedata"><xsd:element name="dataroot"><xsd:complexType><xsd:sequence><xsd:element ref="Query5" minOccurs="0" maxOccurs="unbounded"/></xsd:sequence><xsd:attribute name="generated" type="xsd:dateTime"/></xsd:complexType></xsd:element><xsd:element name="Query5"><xsd:annotation><xsd:appinfo/></xsd:annotation><xsd:complexType><xsd:sequence><xsd:element name="temp" minOccurs="0" od:jetType="text" od:sqlSType="nvarchar"><xsd:simpleType><xsd:restriction base="xsd:string"><xsd:maxLength value="255"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element name="Code" minOccurs="0" od:jetType="text" od:sqlSType="nvarchar"><xsd:simpleType><xsd:restriction base="xsd:string"><xsd:maxLength value="255"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element name="ID" minOccurs="0" od:jetType="longinteger" od:sqlSType="int" type="xsd:int"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema>
<?xml version="1.0" encoding="UTF-8" ?> - <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Query5.xsd" generated="2014-12-02T22:10:47"> - <Query5><temp>h</temp><ID>13</ID></Query5> - <Query5><temp>I</temp><ID>14</ID></Query5> - <Query5><temp>k</temp><ID>15</ID></Query5> - <Query5><temp>l</temp><ID>16</ID></Query5> - <Query5><temp>m</temp><ID>17</ID></Query5> - <Query5><temp>n</temp><ID>18</ID></Query5> - <Query5><temp>o</temp><ID>19</ID></Query5> - <Query5><temp>p</temp><ID>20</ID></Query5> - <Query5><temp>q</temp><ID>21</ID></Query5> - <Query5><temp>r</temp><ID>22</ID></Query5> - <Query5><temp>s</temp><ID>23</ID></Query5> - <Query5><temp>aa</temp><ID>1</ID></Query5> - <Query5><temp>aaa</temp><ID>2</ID></Query5> - <Query5><temp>bbb</temp><ID>3</ID></Query5> - <Query5><temp>cccc</temp><ID>4</ID></Query5> - <Query5><temp>a</temp><ID>5</ID></Query5> - <Query5><temp>b</temp><ID>6</ID></Query5> - <Query5><temp>c</temp><ID>7</ID></Query5> - <Query5><temp>d</temp><ID>8</ID></Query5> - <Query5><temp>e</temp><ID>9</ID></Query5> - <Query5><temp>f</temp><ID>10</ID></Query5> - <Query5><temp>g</temp><ID>11</ID></Query5></dataroot>
Hello,
A C# database app will actually time out when run from a scheduled task.
The app runs fine from Visual Studio.
Any suggestions?
I am using Windows 7 Ultimate with 24 GBs of ram.
williamj
williamj
So im having this problem with ReadProcessMemory. Cant figure out why it fails suddenly.
ptrPlayer fails when i try to read 'hw.dll' twice. ptrTeam and ptrLocalIndex works like it should.
ptrPlayer's sig is correct (if i add it before localindex, ptrLocalIndex fails and ptrPlayer is successful).
Displayed what happened in FindPattern. And 'bBytes' is not read correctly after i scan for ptrPlayer. bBytes.Count() is correct but for some reason the elements arent filled out. Only 0's
RPM works for everything else. Like reading values etc. Just findpattern that fails if i read the same module twice :|
COffsets.ptrLocalIndex = COffsets.FindPattern("hw.dll", CConverter.StringToByteArray("A1 00 00 00 00 8B 0D 00 00 00 00 8D 44 40 03")); COffsets.ptrTeam = COffsets.FindPattern("client.dll", CConverter.StringToByteArray("A1 00 00 00 00 83 F8 01 74 1C")); COffsets.ptrPlayer = COffsets.FindPattern("hw.dll", CConverter.StringToByteArray("A1 00 00 00 00 83 C4 04 83 F8 FF"));
public static IntPtr FindPattern(string strModule, byte []bPattern)
public static byte[] ReadMemory(IntPtr ptrAddress, Int32 Length)
{
if (CProcess.GetModule(strModule) == null)
return IntPtr.Zero;
byte[] bBytes = CProcess.ReadMemory(CProcess.GetModule(strModule).BaseAddress, CProcess.GetModule(strModule).ModuleMemorySize);
for (int i = 0; i < bBytes.Count(); ++i)
{
for (int iPatternCount = 0; iPatternCount < bPattern.Count(); ++iPatternCount)
{
if (bPattern[iPatternCount] == 0x0)
continue;
if (bPattern[iPatternCount] != bBytes[i + iPatternCount])
break;
if (iPatternCount == bPattern.Count() - 1)
return CProcess.GetModule(strModule).BaseAddress + i;
}
}
return IntPtr.Zero;
}
{
byte[] bRet = new byte[Length];
UInt32 UnUsed = 0;
ReadProcessMemory(hHandle, ptrAddress, bRet, (UInt32)Length, ref UnUsed);
return bRet;
}
On a side note: I know the findpattern is poor. Gonna improve it and do all in one scan kinda thing for each module when it works.
Morten Helland
HI, I am new to C#.net . I want to get the dataGridView cellclick cell values to textbox of another form but couldn't found the right method. I have two forms 1. UserPanelfrm and 2. frmAddProjects . UserPanelFrm consists of dataGridView which shows the list of projects from database . I want to show the cell information of the doubled clicked cell to be shown in textboxes of frmAddProjects.
Codes for ProjectClass.cs
public class ProjectClass
{
SqlConnection conn = new SqlConnection(DataConnectionClass.DbConnection);
public int ManageProject(int ProjectID, String BusinessName, String ContactPerson, String Phone, String Address, String CreatedDate, String AssignedTo, String Mode)
{
try
{
int result = 0;
SqlCommand cmd = new SqlCommand("sp_ManageProject", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ProjectID", ProjectID);
cmd.Parameters.AddWithValue("@BusinessName", BusinessName);
cmd.Parameters.AddWithValue("@ContactPerson", ContactPerson);
cmd.Parameters.AddWithValue("@Phone", Phone);
cmd.Parameters.AddWithValue("@Address", Address);
cmd.Parameters.AddWithValue("@CreatedDate", CreatedDate);
cmd.Parameters.AddWithValue("@AssignedTo", AssignedTo);
cmd.Parameters.AddWithValue("@Mode", Mode);
conn.Open();
result = cmd.ExecuteNonQuery();
conn.Close();
return result;
}
catch (Exception ex)
{
throw ex;
}
}
public DataTable SelectAllProjects()
{
try
{
SqlCommand cmd = new SqlCommand("Select ID,ProjectID,BusinessName,ContactPerson,Phone,Address,CreatedDate,AssignedTo from tbl_ProjectInformation", conn);
DataTable dt = new DataTable();
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
dt.Load(dr);
conn.Close();
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
}
Code to call ProjectList to UserPanelfrm dgvProjectDetails:
ProjectClass pc = new ProjectClass();
dgvProjectDetails.DataSource = pc.SelectAllProjects();
Code for cellclick
string myValue;
private void dgvProjectDetails_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
myValue = dgvProjectDetails[e.ColumnIndex, e.RowIndex].Value.ToString();
frmAddProjects ProjectDetails = new frmAddProjects();
ProjectDetails.Show();
}
Ero_Jiraiya
Hello,
first of all - if this thread is in the wrong section then please move it.
I'm experiencing some issues if I'm trying to install Update 4 for VS 2013. The installation fails with the message that .NET Framework is required for the setup but I have .NET Framework on its latest version (4.5.1).
The error message can be found here: http://i.imgur.com/yalgBHr.png
I tried the dotNetFx-Cleaner which killed every version and then I tried to install them again.
Nothing has changed, I tried to repair the installation, nothing.
Does anyone know how to fix this? I read that many people formatted their computers and reinstalled everything but this is not an option for me.
I can't even uninstall VS because the uninstaller say that the .NET Framework is required.
I've been chasing my tail for a few days trying to learn how to update my SQL table from DataTable as it is being edited in DataGridView (change column value, add row, delete row). I've been working with C# about 2 months and am very green. I've gone down a dozen paths that lead to a dead end and have backed out most code to where I think I should be to proceed.
I'm requesting assistance in getting this to work.
So I have several questions:
public partial class frmAttributeMap : Form { SqlDataAdapter da = new SqlDataAdapter(); public DataTable tblvAttributes; public DataSet dsVX130; public frmAttributeMap() { InitializeComponent(); //tAttributes dsVX130 = new DataSet("VX130"); tblvAttributes = new DataTable("vAttributes"); tblvAttributes.Columns.Add("DatabaseName"); tblvAttributes.Columns.Add("DWPhysicalSchemaName"); tblvAttributes.Columns.Add("DWPhysicalTableName"); tblvAttributes.Columns.Add("DWFieldName"); tblvAttributes.Columns.Add("DWFieldDataType"); tblvAttributes.PrimaryKey = new DataColumn[] {tblvAttributes.Columns["DWPhysicalSchemaName"], tblvAttributes.Columns["DWPhysicalTableName"]}; tblvAttributes.RowChanged += new DataRowChangeEventHandler(Row_Changed); tblvAttributes.ColumnChanged += new DataColumnChangeEventHandler(Column_Changed); }
private static void Row_Changed(object sender, DataRowChangeEventArgs e) { Console.WriteLine("Row_Changed Event: name={0}; action={1}", e.Row["name"], e.Action); //<DataTableRow>[<DataColumn>, DataRowVersion.Original] } private static void Column_Changed(object sender, DataColumnChangeEventArgs e) { Console.WriteLine("Column_Changed Event: name={0}; Column={1}; original name={2}", e.Row["name"], e.Column.ColumnName, e.Row["name", DataRowVersion.Original]); } private void bindingSource1_PositionChanged(object sender, EventArgs e) { //breakpoint da.Update(tblvAttributes); }
if (Directory.Exists(@"C:\Hysteria\game")) { StartGame(//Here i need some arguments...); } //Here is the void function which i wanna call if there is folder existing.. public void StartGame(string username, string session)Really cannot figure out what are those arguments for username and session,i tried all things that i know.And (null, null) doesn't work.