John Oliver (UK)MSP, VSIP's Q&A profile
Visual C# FileStream - encoding
Hi I receive files as byte array from a Web service along with the enconding for the same. I want to write the byte array into a file in the local system and I would like to write the file in the same encoding that I recieived from the service. I tried FileStream to write into the local file system, but I don't find any options to specify the encoding. Please let me know how to acheive this. I'm using .NET 1.1 Thanks in advance, Karthick. hi, you can use streamreader and streamwriter to read from a stream, you can set the default incoding or you can set a bool value to detict the default incoding FileStream fs = new FileStream ( "" ); StreamReader sr= new St ...Show All
Visual Basic datagrid column values to label1.text
hi for example;I showed my query result (select id,email from mail) on datagrid. there is four rows. id email 1 mail1 2 mail2 3 mail3 4 mail4 I want to write email values to label1.text. label1.text="mail1;mail2;mail3;mail4" how can I do Dim sb As New System.Text.StringBuilder For i As Integer = 0 To Me .DataGridView1.Rows.Count - 1 sb.Append( CStr ( Me .DataGridView1.Item("Email", i).Value)) sb.Append(" ,") Next Me .Label1.Text = sb.ToString Loop through the values in the grid , append the values toa string builder and display ...Show All
SQL Server inserting data for testing
This is the code I'm using to insert data into a table with data from one table, but changing a single column to prevent duplicates and to increase the number of rows. I know I'm missing something easy, but... what is it thx, Kat code to create the table: CREATE TABLE [OrdDetails] ( [OrderID] [int] NOT NULL , [ProductID] [int] NOT NULL , [UnitPrice] [money] NOT NULL , [Quantity] [smallint] NOT NULL , [Discount] [real] NOT NULL , CONSTRAINT [PK_OrdDetails] PRIMARY KEY CLUSTERED ( [OrderID], [ProductID] ) ON [PRIMARY] ) ON [PRIMARY] GO I inserted all the data from the [Order Details] table, now I'm trying to reinsert the data but changing the PK constraint to prevent error. Seems like this should work. truncate table Ord ...Show All
.NET Development Returning Exceptions with ExecuteScaler from RAISERROR in a SQL Proc
I am experiencing that I am not able to return an exception from a stored procedures that I call using ExecuteScaler if my select statement is before the RAISERROR statement. I do understand that if I use ExecuteReader I have to perform a reader.NextResultSet to get an exception to fire. This is working fine. Is there any way at all to return an exception with ExecuteScaler(after the select) or is this not possible. I'm looking for the answer so I can avoid using this method entirely and move to using a reader. Is using a reader and calling NextResultSet the next best option if I want to ensure all exceptions get returned and have good performance even if it is only returning one value I'm assuming this will perform bett ...Show All
Visual Studio 2008 (Pre-release) DateTime display format in GridView
Does anyone know how to format the DateTime text and display it in my grid view. Right now the format is rather arbitrary. xmlns:local = " clr-namespace:BonusPromoWPF " then later: DisplayMemberBinding = " {Binding Path=startDate, Converter=local:DateTimeConverter} " wont parse XAML file, throws exception ...Show All
SQL Server Foreign Key constraint conflict
Hi, I am fairly new to SQL server Express and I have quite a simple database set up and I am trying to test it out with data. I have “Pain Reading” and “Worsen Factors” tables with a 1: M relationship. The primary key in the Pain reading table is ReadingID which is being set using getdate() for the default value. I am getting the following error when attempting to add a new row to the “Worsen Factors” table: No row was updated The data in row 1 was not committed. Error source:.Net SqlClient Data Provider Error Message: The insert statement conflicted with the FOREIGN KEY constraint "FK_WorsenFactor_PainReading1". The confilct occurred in database "paindata", table "dbo.PainReading& ...Show All
SQL Server How can one user view other users that belong to a database role?
After upgrading my database from SQL2000 to SQL2005 I have noticed a change in behavior of sp_helprolemember. In SQL2000 I could connect as 'user1' and use sp_helprolemember to find all users that belong to a certain role. In SQL2005 sp_helprolemember seems to only show me the roles that connected user belongs to. For example, if I connect as 'user1' I only see the roles that 'user1' belongs to. Any advice on how to duplicate the behavior from SQL2000 So how do you resolve it Sorry Jens but I dont understand what you are getting at. Are you saying that you must be db_owner for sp_helprolemember to work as it did in SQL 2000 Are there any MVP's reading this We need a resolution, I dont have time ...Show All
.NET Development How to check if a column exists in a datareader
I'm up against this problem for which I'm surprised to find no help. I want to check if a column exists in the datareader before attempting to read it. If i don't check i get the indexOutofRange exception. There is similar functionality with datatable where we do dt.Columns.IndexOf("ColName") But how do we do this with datareader Good question. I don't know why they didn't add a method to check for the existence of a column that did not throw an exception. I assume they have some good reason, but I never looked into it. Throwing and catching exceptions like that is a bad practice. I probably shouldn't have even mentioned it as I wouldn't put code like that into production, even thou ...Show All
Software Development for Windows Vista wpf and cardspace
Im trying to develop a small application which opens a infocard and use it as user and password to connect to a sql database using a service in framework 3.0. It seems that every example i have tried or seen doesnt work. I am using the release of framework 3.0 on vs2005. Thanks ...Show All
Visual Studio 2008 (Pre-release) ColorAnimation, Binding From Property
Hi guys, May be someone knows how can I bind "From" Property of the ColorAnimation list.cs /////////// private Color m_ListColor; public Color ListColor { get { return m_ListColor; } set { m_ListColor=value; OnPropertyChanged("ListColor"); }} list.xaml /////////////// <ColorAnimation Storyboard.TargetName="fillb" Storyboard.TargetProperty="(SolidColorBrush.Color)" From="{Binding Path=ListColor}" To="#111111" Duration="0:0:0.1" /> There is an exception in Presentationframework.dll Appreciate any help, Irina try changing From="{Binding Path=ListColor}" to From="{Binding E ...Show All
Gadgets Gadget Piracy
Vista hasnt been out for long but we are already seeing a big issue relating to gadgets which is piracy. I have already seen probably 5 examples of people taking someone elses gadget, making a few changes and re-releasing it. I have been developing widgets/gadgets for Mac OS X and Yahoo Widget Engine for 2 years now and i dont think i can even think of 5 similar cases in that time. As far as im concerned unless a gadget specifically states that you may modify and re-release it then those people are breaking copyrights. Just because you can view the source of a gadget that does not mean it should be considered open source in a typical sense. I've released more then 25 widgets/gadgets over the past 2 years and ive never had a proble ...Show All
Windows Forms Windows Application by C# VS 2005 !!!
Hello, I have a bindingNavigator in my application, which I added a Save Button on it. What should i write in this Button's Click Event to save inserted, edited, and deleted records. I have a field that for some reason I make it null at runtime. When I'm going to save the changes on the screen, I use EndEdit() method, but as soon as use this method, it turns the value of that field from null to 1. Does anybody have any idea about this weird action !!!!!!!!!!!!!!! Is C# a good tool for developing Windows Applications !!!!!!!!!!!!! Thanks in advance. Hello, Thanks for your reply. What you said is exactly what I do, but in the case of entering a new record (without moving to another reco ...Show All
Software Development for Windows Vista ICameraControl
How can i use this interface in VB.NET application What Requirements should i include in VB.net Application to use ICameraControl interface plz help me thnks SEE THIS WEBCAM http://www.creative.com/products/product.asp category=218&subcategory=219&product=13979 DOES THIS CAMERA support the ICameraControlInterface !! ...Show All
Visual Studio Sandcastle - how to insert 'line break' within <summary> tag
Hello, I tried to insert some line break using <br/>. However, this has no effect. They are reflected in the xml file generated at VS compilation time but ignored by SandCastle when generationg the chm file. This was supported by NDOC under vs2003. Does anyone know how to insert such line break Thanks, Jose hi, Thanks,.... I had tried it several times before but it never worked fine..... Reading your email I realised that all tags should have closing-tags included (img and /img)...... We are talking XML-here... offcourse!!! Thanks for your reply. Kind regards, Stephan Smetsers ...Show All
Visual C# Request.QueryString
In VB, we can use: s = Request.QueryString("name") In C#, when I use it the same way: s = Request.QueryString("name"); or another way: s = Request.QueryString["name"]; compilation error is " CS1513: } expected ". Why You are right, the error may not be caused by Request.QueryString. Now I change the code as follows, the same error still exists: <%@ Register TagPrefix="article" Namespace="article" Assembly="webcolumn"%> <%@ Register TagPrefix="article" Namespace="article" Assembly="articlecolumn"%> <script language="C#" runat="server"> void Page_Load(Object sender, EventArgs e) { if (!Page.IsPostBack) { string s; s = Request. ...Show All
