|
alias bill wrote: I will never learn everything necessary to be competent
Don't sell yourself short! C# isn't *that* hard. I don't know everything by a long way and still ask questions here myself from time to time, but I consider myself competent.
I don't have any C# books, so I can't recommend any personally. All my knowledge has been gained from studying articles/blogs/MSDN - and with the help of CodeProject, I've learned enough to know when what I am reading is rubbish or is good stuff.
Just keep at it, and with an internet connection you have all you need, though a good book will help if you can find any recommendations.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
i don know what kind of design you have in mind for your application
you can also use usercontrols like pages
create a single form that you fill with the usercontrols designed like page, then bring to front the page you want.
You can do this insead of creating child forms, if you don´t want to open new windows and run all the show in the same window
you have to manage delegates here
nelsonpaixao@yahoo.com.br
trying to help & get help
modified on Thursday, August 6, 2009 8:05 PM
|
|
|
|
|
Hello,
I am trying to use a Session Variable in an update command and the error that I continue to get is:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Server tags cannot contain <%...%>constructs.
It also says that the Datasource is not well formed when I try to enter it in. Could someone help me figure out how to use this?
The session variable I am trying to bring over is a global temp table name. Below is the code.
<asp:SqlDataSource ID="FAR15DataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:Cost_ModelConnectionString %>"
SelectCommand="SELECT Service_Tower_Code, WBS_Code, Ownertype, Compensation_Code, Compensation_Rate, Far_East_FTE, Hawaii_FTE,Mid_Atlantic_FTE, NCR_FTE, North_Midwest_FTE, Northeast_FTE, South_FTE, Southwest_FTE
FROM fn_enterprise_positions(1)"
UpdateCommand="UPDATE <%=Session["TableName"]%> SET Far_East_FTE = @Far_East_FTE, Hawaii_FTE = @Hawaii_FTE, Mid_Atlantic_FTE = @Mid_Atlantic_FTE, NCR_FTE = @NCR_FTE, North_Midwest_FTE = @North_Midwest_FTE, Northeast_FTE = @Northeast_FTE, South_FTE = @South_FTE, Southwest_FTE = @Southwest_FTE
WHERE Service_Tower_Code = @Service_Tower_Code AND WBS_Code = @WBS_Code AND Compensation_Code = @Compensation_Code AND worker_code = @worker_code">
<UpdateParameters>
<asp:FormParameter Name="Service_Tower_Code" FormField="Service_Tower_Code" />
<asp:FormParameter Name="WBS_Code" FormField="WBS_Code" />
<asp:FormParameter Name="Compensation_Code" FormField="Compensation_Code" />
<asp:FormParameter Name="worker_code" FormField="worker_code" />
<asp:FormParameter Name="Compensation_Rate" FormField="Compensation_Rate" />
<asp:FormParameter Name="Far_East_FTE" FormField="Far_East_FTE" />
<asp:FormParameter Name="Hawaii_FTE" FormField="Hawaii_FTE" />
<asp:FormParameter Name="Mid_Atlantic_FTE" FormField="Mid_Atlantic_FTE" />
<asp:FormParameter Name="NCR_FTE" FormField="NCR_FTE" />
<asp:FormParameter Name="North_Midwest_FTE" FormField="North_Midwest_FTE" />
<asp:FormParameter Name="Northeast_FTE" FormField="Northeast_FTE" />
<asp:FormParameter Name="South_FTE" FormField="South_FTE" />
<asp:FormParameter Name="Southwest_FTE" FormField="Southwest_FTE" />
</UpdateParameters>
</asp:SqlDataSource>
I did originally have a <asp:SessionParameter Name="TableName" /> inside the update parameters but that didnt seem to do anything. Thanks for your help!
John Michael
|
|
|
|
|
This is C# Forum. Please post it on ASP.NET Forum
|
|
|
|
|
Hi,
I have been trying to populate a table in word from C#, originally i was using this code which i found on an article on this site and just adapted:
public void CreateFileColumn(ArrayList array, Array Numbe)<br />
{<br />
object missing = System.Reflection.Missing.Value;<br />
object fileName = "normal.dot";<br />
object newTemplate = false;<br />
object docType = 0;<br />
object isVisible = true;<br />
Object oUnit = Word.WdUnits.wdCell;<br />
<br />
<br />
wordApp = new Word.ApplicationClass();<br />
wordDoc = wordApp.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible);<br />
wordApp.Visible = true;<br />
wordDoc.Activate();<br />
<br />
wordApp.Selection.Tables.Add(wordApp.Selection.Range, 1, 8, ref missing, ref missing);<br />
<br />
wordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;<br />
wordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;<br />
<br />
<br />
foreach (string part in Numbe)<br />
{<br />
wordApp.Selection.InlineShapes.AddPicture(@"C:\Users\Jon\Documents\Nick\Chin Font Files\" + part + ".jpg", ref missing, ref missing, ref missing);<br />
wordApp.Selection.MoveRight(ref oUnit, ref missing, ref missing);<br />
}<br />
<br />
<br />
<br />
<br />
}
all this does is take an image from the folder listed and place them in a cell in the table, and keeps doing this until the arraylist is empty. However, it has got to the point now where i need to be more precise then just move right, i need to select which table i am in and what cell i am placing the image in. I know there is ways using cell[] and table[], but i don't know how to implement this in this piece of code.
Any help would be greatly appreciated
|
|
|
|
|
try using this
Word.Range rngC
rngC = YourTableName.Cell(i, j).Range
rngC.InlineShapes.AddPicture(with all the params you need)
i = column
j = row;
|
|
|
|
|
how do i know/tell what the table name is?
thanks for your help so far.
|
|
|
|
|
i'll paste you some of my code and hope it will help you
public void insertTable(Word.Document oDoc, int nr, int nrMoment)
{
strct.bla ++;
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc";
Word.Table oTable;
Word.Table oTable1;
Object style = "Table Grid v2";
Word.Range rngC;
Object defaultTableBehavior = Type.Missing;
Object autoFitBehavior = Type.Missing;
object rng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
object oPageBreak = Word.WdBreakType.wdPageBreak;
Word.Paragraph oPara = oDoc.Paragraphs.Add(ref rng);
oPara.Range.InsertBreak(ref oPageBreak);
oPara.Range.Font.Bold = 1;
oPara.Range.Font.Size = 14;
oPara.Range.Font.Name = "Book Antiqua";
oPara.Range.set_Style(ref styleHeading2);
oPara.Range.Text ="M" + strct.nr[1].ToString() +" "+ strct.titluCadru[strct.bla].ToString();
oPara.Range.InsertParagraphAfter();
Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oTable = oDoc.Tables.Add(wrdRng, 1, 1, ref defaultTableBehavior, ref autoFitBehavior);
oTable.set_Style(ref style);
oTable.ApplyStyleLastColumn = false;
oTable.Range.ParagraphFormat.SpaceAfter = 5;
rngC = oTable.Cell(1, 1).Range;
rngC.Font.Name = "Book Antiqua";
rngC.Font.Bold = 0;
rngC.Text = "Obiectivele educaţionale acoperite de moment, submoment şi itemul de învăţare \r\n Obiective operaţionale";
rngC.ParagraphFormat.SpaceAfter = 3;
rng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
Word.Paragraph oPara1;
oPara1 = oDoc.Paragraphs.Add(ref rng);
oPara1.Range.Font.Bold = 1;
oPara1.Range.Font.Name = "Book Antiqua";
oPara1.Range.Text = "O1";
oPara1.Format.SpaceAfter = 2;
wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oTable1 = oDoc.Tables.Add(wrdRng, nr + 11, 2, ref defaultTableBehavior, ref autoFitBehavior);
oTable1.set_Style(ref style);
oTable1.ApplyStyleLastColumn = false;
oTable1.Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
oTable1.Range.ParagraphFormat.SpaceAfter = 6;
rngC = oTable1.Cell(1, 1).Range;
rngC.Font.Bold = 1;
rngC.Font.Name = "Book Antiqua";
rngC.Text = "Descriere";
}
}
to use a certain table you can use a bookmark, create it from scratch, or put it in an array (haven't used this last one). Hope this helps
|
|
|
|
|
Sorry if i seem a bit thick, could you paste an example of how to call that routine, what would you place in the first argument? This is all rather new to me.
|
|
|
|
|
Can someone help with an issue I'm having with a CheckListBox.
I have two Forms lets say Form1 - Form2, Form2 contains a CheckListBox that accepts input from the user I've also created a Foreach statement to Iterate through the CheckListBox on Form2 Form1 has a button coded to call Form2 Foreach method everything seems to work except for one problem when making the call to Form2 the Foreach method indicates the CheckListBox is Null although the CheckListbox contains item's, so as a test I created a button on Form2 and wired it to call the Foreach method on Form2 and all works the Foreach Method see's the Item's and perform the Iteration on all Item's where as making the call from Form1 indicate a Null CheckListBox. I'm not sure if this is a Threading issue do to the fact Form1 is creating a new Object to access Form2 Foreach method ?
FORM1
button1_Click(object sender, EventArgs e)
{
List.Form2 List = new List.From2();
List.ChkList();
}
FORM 2
Public void ChkList()
foreach (string s in checkedListBox1.Items)
{
if (s.Equals(dt))
{ Do Work
}
FORM2 Test Button.
button2_Click(object sender, EventArgs e)
{
List.Form2 List = new List.From2();
List.ChkList();
}
|
|
|
|
|
Works without a problem on my system using the setup you described. It shouldn't be a threading issue based on what you said. It more than likely is an ordering issue of when the items in the list get populated. If you populate them on Load (only called when the Form is shown) or via some other event, those won't be called on construction. So, you might want to start there. Just place breakpoints around the sections that load data into that list and go from there.
|
|
|
|
|
the situation is completely unclear.
is it From2 or Form2?
is the "List" form shown at all, I see no List.Show()?
where is the declaration of checkedListBox1? and its assignment?
etc etc
and how could it be a threading issue, you haven't shown anything related to threads?
BTW: your button2_Click() method probably proves nothing as it (1) only can work after its Form is fully loaded and shown, (2) creates yet another "From2", and (3) is located inside Form2 class, so it is completely different from what button1_click() is doing.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks Luc, Im new to the forum and was in a rush and left out details on the other hand the Info Dave and Andrew left might be enough to get me back on track.
|
|
|
|
|
What you're trying to do, or at least the way you're trying to do it, seems a little bit strange.
This code works for me. Just a default project with a Form1 and Form2 added - everything else in done in code.
using System;
using System.Windows.Forms;
public partial class Form1 : Form
{
private Form2 form2;
public Form1()
{
InitializeComponent();
Button button = new Button();
Controls.Add(button);
button.Click += button_Click;
}
void button_Click(object sender, EventArgs e)
{
CheckForm2Instance();
form2.DoStuffWithCheckBox();
}
void CheckForm2Instance()
{
if (form2 == null)
{
form2 = new Form2();
form2.FormClosing += form2_FormClosing;
}
form2.Show();
}
void form2_FormClosing(object sender, FormClosingEventArgs e)
{
form2.FormClosing -= form2_FormClosing;
form2 = null;
}
}
using System.Windows.Forms;
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
CheckedListBox checkedListBox = new CheckedListBox();
Controls.Add(checkedListBox);
checkedListBox.Items.AddRange(new object[] { "A", "B", "C" });
}
public void DoStuffWithCheckBox()
{
MessageBox.Show("Doing Stuff");
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Dave that worked I modified just a bit of the code and it worked out.
Thanks
|
|
|
|
|
Hi there i'm trying to read data from SQL
This is my Class
class Sql
{
public SqlConnection sqlCon;
public void connectToSql (string adr)
{
sqlCon = new SqlConnection(adr);
try
{
sqlCon.Open();
}
catch (Exception e)
{
string str = e.ToString();
using (StreamWriter sw = new StreamWriter ("out1.txt"))
{
sw.WriteLine (e.ToString());
}
}
}
public void readSql(String col, String tab)
{
try
{
SqlDataReader sqlRead = null;
SqlCommand sqlCmd = new SqlCommand("SELECT * FROM " + tab + " WHERE Column =" + col, sqlCon);
sqlRead = sqlCmd.ExecuteReader();
using (StreamWriter sw = new StreamWriter ("out.txt"))
{
sw.WriteLine(sqlRead.ToString());
}
}
catch (Exception e)
{
using (StreamWriter sw = new StreamWriter ("out.txt"))
{
sw.WriteLine (e.ToString());
}
}
}
public void exitSql()
{
sqlCon.Close();
}
}
}
And this is the error that i get
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at longliveSorin.functiiSql.Sql.connectToSql(String adr) in D:\work\cte\C#\cifru\longliveSorin\longliveSorin\functiiSql\Sql.cs:line 19
Can someone help me plz
|
|
|
|
|
Could be your connection string, can you post it please
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
private Sql sql = new Sql();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
String adr = @"Address=localhost;Initial Catalog=Cifru;connection timeout=10;";
sql.connectToSql(adr);
sql.readSql("NumePrenume","contacte");
sql.exitSql();
}
I tried it without the @ but it still didn't work
|
|
|
|
|
Looks like your connection syring is all wrong. Take s visit to connectionstrings.com/[^]
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Check if your connection string is correct. You can find all sorts of connection strings here[^].
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thank you i'll take a look
|
|
|
|
|
Hi,
There is a compiler switch to create pdb symbols in VC++. What needs to be done to create symbols for a C# app?
I couldn't find any setting in the project properties page. I have noticed that when I compile the project, it creates a pdb in
the debug/release folder.
MSDN says we can use csc /debug /pdb:tt t.cs to create PDB, but is there a way to create PDBs from the GUI?
Thanks in advance,
Nachiket
|
|
|
|
|
Yes, by compiling your code.
The file maps the binary back to the source-code, and is as such, dependent on the binary. Without the binary there is nothing to map.
|
|
|
|
|
Thanks Eddy.
So what kind of symbols are created when I compile the code? public or private?
I am looking for a way to create private symbols so that I can see source file and line number information from a crash dump through windbg.
|
|
|
|
|
I just copy them to the bin\debug-directory. You might be interested in this[^] article.
I are Troll
|
|
|
|
|