|
Hi
my question is that how to insert relational data with tableAdapter. for example we have 2 tables:
Orders (Parent Table)
OrderDetails (Child Table)
now, we want to insert new Order and some OrderDetails record in Relational mode :
Insert new Order & it's OrderDetails together
Order1
OrderDetails1
OrderDetails2
OrderDetails3
Insert Operation ...
as u can see in my scenario, the OrderDetails to be inserted is DataTable, not a single record. i found this article, but indeed, my problem was no solved Because :
1. it's implement by DataAdapter and i'm using TableAdapter. i think TableAdapter has a built in functionality to do this.
2. it's a single child row, wheras in my scenario the child is DataTable.
any Help ?
Thanks
|
|
|
|
|
Hi,
I am binding data to the Combobox from the database using the DataSource,DisplayMember and ValueMember.
I want to display a default text named --Select-- at index 0 in the Combobox, apart from the values in the database. How do I achieve this? I am using DataSet.
Thanks in Advance.
|
|
|
|
|
You can add manually by using ListItem.
Create a ListItem with a corresponding value then insert it into the existing Items of the combo box..
You should do this after databindin event.
|
|
|
|
|
I do this all the time, so much so that I create a method the inserts a row at position 0 in the data table. Create a new row based on the table, populate it (relevant fields only) with your default value and use table.rows.insert.
public static DataTable TableAddRow0(DataTable oTable, int iLabelCol, string sLabel)<br />
{<br />
try<br />
{<br />
DataRow oRow = oTable.NewRow();<br />
if (oTable.Columns.Count > 1)<br />
{<br />
oRow[0] = 0;<br />
oRow[iLabelCol] = sLabel;<br />
}<br />
else<br />
oRow[0] = sLabel;<br />
<br />
oTable.Rows.InsertAt(oRow, 0);<br />
return oTable;<br />
}<br />
catch (Exception)<br />
{ throw; }<br />
}
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I am using Visual Studio 2008, i am writing a small code for Net Compact Framework. I use Windows Mobile Emulator. Now my code is in Directory "c:\Works\UI\MyProj". Now when i use following command
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
it returns \Program File\MyProj instead of "c:\Works\UI\MyProj". I want to access another folder in the same directory called Images. I use something like this
MyImage = new Bitmap(path + @"\Images\myImage.bmp");
but when i try to execute the aove statement it returns the following error
Could not find a part of the path '\Program Files\MyProj\Images\myImage.bmp'.
How do i access the Images folder in my project directory
Regards
Hiten Parmar
|
|
|
|
|
Check out the System.IO.Path class. Specifically, you may find Path.GetFullPath() and Path.Combine() useful.
If your image is located in a subdirectory in the directory of your app, you could just do
MyImage = new Bitmap("Images\myImage.bmp"); . You don't need the full path there.
|
|
|
|
|
Hi everyone,
Iv'e created small application that sends files to a server using ftp.
I got 2 network adapters on my machine.
when i monitoring the communication i see that each time a different network adapter is sending the package.
My question is can i select which network adapter to use in the code level (if yes how) or it should be a netwok setting.
thanks in advanced
|
|
|
|
|
Hi
I had an application of BHO. It had been developed using visual Studio 2005. Actually, it main aim is to read the text of HTML page and write that into a text file. I had checked this on IE6 and IE7 in various PC's. before that I had installed .Net Framework 2.0 also. If I register that dll in some pc's it works perfectly on both IE6 and IE7. but on some PC's it doesn't write the html page's text into a file? what may be the problem?
How on earth can I figure out why there is a difference? I have compared tools>internet options>advanced. The settings on both computers are identical. They also both have all 4 security zones at the same level and they both have the same general settings.
modified on Monday, April 20, 2009 1:24 AM
|
|
|
|
|
hello
VBA calling C# code anyone? I'm looking for an article/tutorial.
Thanks
dev
|
|
|
|
|
|
Thanks - seen better ways to do this (than wrapping it in COM/ATL server) now with Excel 2008?
I remember I done ATL server way back don't like this. You've got to marshall data into BSTR and all that (even thrown out the book now), just don't like the mechanism.
For example, this looks about right: http://www.c-sharpcorner.com/UploadFile/jodonnell/Excel2003fromCSharp12022005021735AM/Excel2003fromCSharp.aspx[^]
This article shows you how to generate Excel doc with C#, setting cell value via Excel object model and all. But still to call say C# component/dll from Excel VBA code... seems like COM is the only way?
But
dev
|
|
|
|
|
COM isn't ideal, but I don't know any other options unfortunatly. The example you posted seems to be about replacing VBA in Excell with C#. I doubt that you're looking for Excell-automation-article's, so that's not going to help either.
Seems COM is the way to go, sorry
I are troll
|
|
|
|
|
haha - COM is still alive afterall.
dev
|
|
|
|
|
Eddy Vluggen wrote: COM isn't ideal, but I don't know any other options unfortunatly.
Neither do I, and I've looked in the past. On the plus side as long as you keep your types within the allowed values on the .net side (this doesn't cause any sort of compile time error, the method's just not exposed in COM) all you really have to do is to tell the compiler to make it a com class. From proof of concept testing, it's reasonably painless.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
How can perform following conversion (string to datetime)?
string s="January 1, 1986" to DateTime datatype
shahdat
|
|
|
|
|
string s = "January 1, 1986";
DateTime dt;
if (!DateTime.TryParse(s, out dt))
else
|
|
|
|
|
Dude try this
String s = "January 1, 1986";
DateTime t1 = DateTime.ParseExact(s, "MMMM d, yyyy", null);
|
|
|
|
|
Dear all,
I have a procedure that works nice I guess.
Exm-
CREATE PROCEDURE Insert_TeacherProfile
(@Ins_ID int, @Yr smallint, @Querter int, @Tcr_ID smallint, @Tcr_Nm nvarchar,
@Gender smallint)
AS
INSERT INTO TeacherProfile
(Ins_ID, Yr, Querter, Tcr_ID, Tcr_Nm, Gender)
VALUES
(@Ins_ID, @Yr, @Querter, @Tcr_ID, @Tcr_Nm, @Gender)
Now you can see the all field not allaw null except Gender(allaw null) field. But In the software when I pass no (null) value in Gender filed it show error. Anyway to pass null value in this query. I need two option, value or null anything I can be inserted. Is there anyway to do it inside this procedure?
If you dont understand tell me.
Thanks
|
|
|
|
|
WE have a SQL forum, but if you want to be able to pass null in then use isnull to change the nulls to a default value.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
sorry I ve done mistake for posting in this section.
But my default is null also.
Thank you
|
|
|
|
|
NOt sure how you are passing a null value to the gender field - show us the code and we may be able to help - also what is the error you are getting?
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I dont wanna do it by coad thats why I want to know how to do.
thanks
|
|
|
|
|
soulidentities wrote: If you dont understand tell me.
It is not clear. Are you looking for solution to pass NULL to the @Gender parameter? If yes, you can do this in procedure level or in code level. In procedure level,
CREATE PROCEDURE Insert_TeacherProfile
(
@Ins_ID int,
@Yr smallint,
@Querter int,
@Tcr_ID smallint,
@Tcr_Nm nvarchar,
@Gender smallint = NULL)
AS
.... Or use DbNull.Value as parameter value from the code.
yourCommand.Parameters.AddWithValue("@Gender",DbNull.Value)
|
|
|
|
|
I know this coad that you mentioned.
i also using this coad. My need is by using this coad when it dones get any value from textbox the procedure automatically get null.
Is it possible??
|
|
|
|
|
well if you textbox entry is stored in an integer
e.g. int gender = SomeMethodThatConvertsTextToAnInteger(myTextBox.Text);
you could make gender a nullable int
int? = SomeMethodThatConvertsTextToANullableInteger(myTextBox.Text);
then when you pass that value to the SP (using the code supplied earlier in this thread) its value will be null.
Or you can say somethiong like
if (myTextBox.Text == string.Empty)
yourCommand.Parameters.AddWithValue("@Gender",DbNull.Value);
else
yourCommand.Parameters.AddWithValue("@Gender",myTextBox.Text);
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|