|
I want a detailed hierarchy of exception classes.Specially ones that handle database exceptions.Please help...
|
|
|
|
|
MSDN[^]
For database exceptions, refer to the documentation for the database you are using as they are product specific.
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)
|
|
|
|
|
hellow world !
i need to convert access file to sdf fpr Pocket pc
i need to convert it in the PC (not in my PPC)
how can i do it ?
than'k for any help
|
|
|
|
|
Hi,
i have some images stored in sql database and is all ok. They are saved as a byte[] and i load them into the c# application.
So, i was wondering about how can i have a byte[] in a c# solution (design time not runtime time), well i want to add a byte [] to the solution not image file!!!
Can i do that? is not really important, but i like the way pictures are stored in sql kind of stealth mode.
Thanks
nelsonpaixao@yahoo.com.br
trying to help & get help
modified on Friday, October 24, 2008 8:13 PM
|
|
|
|
|
You can but it's not very efficient as the byte array will need to be serialized by the designer for it's value to persist.
If you want to do it, it's probably easiest to wrap a List<byte> in a component, and call it's ToArray method to get the byte array and it's Clear + AddRange methods to set a byte array.
I don't see what advantage you will gain by doing this though.
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)
|
|
|
|
|
|
Hi,
i created a folder and added a few icons there (i embeded them after), and i want to load them in a label only in some ocasions (other ocasions remains with no icon), the bellow code is for bitmap but not for icons! well it loads but i get edges in white color
Assembly myAssembly = Assembly.GetExecutingAssembly();
Bitmap mybit = new Bitmap(myAssembly.GetManifestResourceStream("UserControl_Page.icons.error.ico"));
Image img = Image.FromHbitmap(mybit.GetHbitmap());
ToolStripStatusLabel_InfoBottom.Image = img;
how can i do this for an icon file???
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I am working on a SDK. It is currently for our use, but one day it will be licensed to our customers. I need a way to ensure that the only code that uses the SDK is our code. Our code is signed (Strong Name). I was thinking that it would be great if there is an Init function or Load event I could use to check that the assembly loading mine was signed with our key. Does such a thing exist? Do you have an alternative idea?
Pat O
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
AppDomain.AssemblyResolve
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Thanks, I was aware of that. I was hoping for something that is called on code within the assembly. Again the goal is to enforce licensing, therefore relaying on someone to register my licencing code prior to using my SDK seems unlikely to work. I guess I could ask the more general question how do others handle licensing?
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
Hi All,
I m using a windows service for calling a web service to insert some data in Db in set interval. When i run exe of my windows service, everything is working perfectly, but when i m creating setup of windows service and deploying it, its not updating data in DB. I don't know the problem with setup. I m using installer in windows service and added custom actions in setup. Even setup if installing as expected and running the service after installation it, but after that i can't see any changes in my data.
Can any one help me in this issue.......
Thanks in advance
|
|
|
|
|
You have to narrow down where the problem is. Is it in calling the Web Service? Is it connecting to the database?? Is it in calling the database functions?? There's too many places to list.
But, I'll take an educated guess at it and say that you used a Trusted Connection to the database, correct? Since services are, by default, run under the Local System account, the SQL server doesn't trust it, so, the connection fails. It's better to use an SQL account that is specificly used by your service to log into the database.
|
|
|
|
|
HI
Can anybody help me i wrote the following code in Console application. Now i want to convert it in Method GetContact(String TeamName). i want to call it from Aspx page. It will get the parameter TeamName and pass it to my SQL Where Clause statement. After the following code will generate the xml and save the file c:temp. RightNow it is working fine but only in Console Application. How i can use this code in MY_FOR_CONTACT(string TeamName). I want to give this code to front end developer who use it to create xml file everytime. and save it c:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
class ExecuteXmlReader
{public static void Main(){
String TeamName = "gta";
String sConnection = "server=HTCWEBDEMO;database=hometrust;user id=ht_admin;password=htc_tr!st";
//String sConnection = "server=zjaffary\\SQLExpress;Integrated Security=SSPI;database=northwind";
SqlConnection mySqlConnection = new SqlConnection(sConnection);
mySqlConnection.Open();
// Get the same data through the provider.
string mySQLStatement = "SELECT Title,FirstName,LastName,PhoneNumber,Faxnumber, email from contactlist where TeamName='" + TeamName +"'; select FirstName, LastName from contactlist where TeamMorty ='True' and teamname='" + TeamName + "';";
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
//SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter("SELECT FirstName,LastName,Title,City from employees; select city from employees;", sConnection);
DataSet myDataSet2 = new DataSet();
myDataSet2.DataSetName = "Contacts";
mySqlDataAdapter.Fill(myDataSet2);
// Write data to files: data1.xml and data2.xml for comparison.
myDataSet2.WriteXml("c:/temp/ContactList.xml");
mySqlConnection.Close();
}
}
|
|
|
|
|
In ASP.NET you have to have permissions to write to the file system. Usually you do not want to allow permission to write to the root, or C, and instead want to write the file to a directory within the site root. Assign read/write permissions to the directory from the IIS snap-in and assign the permissions using the Windows Explorer.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: In ASP.NET you have to have permissions to write to the file system.
Logically, whilst translating this, he ought to replace that with Response.WriteFile() right>?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
That is only if he wishes to output the file to the web user. In his example the file is written to the local file system thus Response.WriteFile would be inappropriate. But then his code requires a lot of inferring so I cannot claim to know exactly what he wants.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Create a folder with ASP.Net and NetworkService user with read/write permission. Not the best way to do this but will work.
|
|
|
|
|
Thanks for your reply. I have done what i was trying to do. But now have another issue. May be you can help for that. it is about the xml file output when it created it showing TABLE and TABLE1 as node in xml how i can change it to meaningful name. My Code is as follows. XML file is at the bottom of the code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
public partial class _Default : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e){
GetEmployees("London");
}
public static void GetEmployees(string City){
//String sConnection = "server=HTCWEBDEMO;database=hometrust;user id=ht_admin;password=htc_tr!st";
String sConnection = "server=ZAFAR-PC\\SQLEXPRESS;Integrated Security=SSPI;database=northwind";
SqlConnection mySqlConnection = new SqlConnection(sConnection);
mySqlConnection.Open();
// Get the same data through the provider.
//string mySQLStatement = "SELECT Title,FirstName,LastName,PhoneNumber,Faxnumber, email from contactlist where TeamName='" + TeamName +"'; select FirstName, LastName from contactlist where TeamMorty ='True' and teamname='" + TeamName + "';";
string mySQLStatement = "SELECT FirstName,LastName,Title,City from employees where city= '" + City + "';select FirstName, LastName from employees where city='" + City + "';";
//SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
DataSet myDataSet2 = new DataSet();
myDataSet2.DataSetName = "Contacts";
mySqlDataAdapter.Fill(myDataSet2);
// Write data to files: data1.xml and data2.xml for comparison.
myDataSet2.WriteXml("c:/temp/ContactList.xml");
mySqlConnection.Close();
}
}
XML FILE OUTPUT
<?xml version="1.0" standalone="yes" ?>
- <Contacts>
- <Table>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
<Title>Sales Manager</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table1>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
</Table1>
- <Table1>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
</Table1>
- <Table1>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
</Table1>
- <Table1>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
</Table1>
</Contacts>
|
|
|
|
|
Try changing the name of the tables:
MyDataSet2.Tables[0].Name = "First Table";
MyDataSet2.Tables[1].Name = "Second Table";
You should be able to rename the tables in the collection.
|
|
|
|
|
I have a method that basically takes a response stream and saves it to a file. This works fine. I want to be able to add a resume feature to this method.
Any suggestions?
My method:
private void WriteToFile(Stream response, Stream output, long sz)
{
if (sz == 0)
{
return;
}
byte[] buffer = new byte[1024 * 64];
long read = 0;
long totalRead = 0;
while ((read = response.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, Convert.ToInt32(read));
totalRead += read;
output.Flush();
}
}
|
|
|
|
|
You have to require the stream to be a seakable stream and then you can just set the position of the stream using the Position property.
Also, don't flush on each write.
byte[] buffer = new byte[1024];
int read = 0;
inputStream.Position = 0;
while((read = inputStream.Read(buffer, 0, buffer.Length)) != 0) {
outputStream.Write(buffer, 0, read);
}
outputStream.Flush();
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
1) The response stream is not seekable since it is a WebResponse.GetResponseStream(). What is my other option?
2) Why is it not a good idea to flush at every write?
|
|
|
|
|
Writing to the stream is controlled by an underlying algorithm, there is no need to flush since it forces the write which may be inefficient. If you want resume downloads using .NET you will probably have to write your own resume code based on the specification of the underlying protocol.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
This works the way it should. I havnt optimized it, so if you want to use this code, look it over and clean it up.
Read the comments. Suggestions are appreciated. Im working on optimizing my code. Too sleepy to do it today.
public void DownloadFile(System.Uri url, string filePath, long sz)
{
Stream r = null;
Stream output = GetFileStream(filePath);
System.Net.WebRequest request = System.Net.WebRequest.Create(url);
System.Net.HttpWebRequest hrequest = (System.Net.HttpWebRequest)request;
hrequest.AddRange(Convert.ToInt32(w.Length));
hrequest.UserAgent = "Mozilla/4.0 (compatiable; MSIE 7.0; Windows NT 6.0)";
System.Net.WebResponse response = null;
try
{
using (response = request.GetResponse())
{
using (r = response.GetResponseStream())
{
using (output)
{
WriteToFile(r, output, sz, w.Length);
}
}
}
}
catch (Exception ex)
{
File.Delete(filePath);
throw new Exception("Could not save " + url, ex);
}
finally
{
}
}
private Stream GetFileStream(string filePath)
{
string fileDirectory = filePath.Substring(0, filePath.LastIndexOf(@"\"));
if (!Directory.Exists(fileDirectory))
Directory.CreateDirectory(fileDirectory);
if (File.Exists(filePath))
return File.Open(filePath, FileMode.Append);
else
return File.Create(filePath);
}
private void WriteToFile(Stream response, Stream output, long sz, long initSize)
{
DateTime startTime = DateTime.Now;
if (sz == 0)
return;
byte[] buffer = new byte[1024 * 64];
long read = 0;
long totalRead = initSize;
while ((read = response.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, Convert.ToInt32(read));
}
w.Flush();
}
|
|
|
|
|
Thanks for your reply. I have done what i was trying to do. But now have another issue. May be you can help for that. it is about the xml file output when it created it showing TABLE and TABLE1 as node in xml how i can change it to meaningful name. My Code is as follows. XML file is at the bottom of the code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
public partial class _Default : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e){
GetEmployees("London");
}
public static void GetEmployees(string City){
//String sConnection = "server=HTCWEBDEMO;database=hometrust;user id=ht_admin;password=htc_tr!st";
String sConnection = "server=ZAFAR-PC\\SQLEXPRESS;Integrated Security=SSPI;database=northwind";
SqlConnection mySqlConnection = new SqlConnection(sConnection);
mySqlConnection.Open();
// Get the same data through the provider.
//string mySQLStatement = "SELECT Title,FirstName,LastName,PhoneNumber,Faxnumber, email from contactlist where TeamName='" + TeamName +"'; select FirstName, LastName from contactlist where TeamMorty ='True' and teamname='" + TeamName + "';";
string mySQLStatement = "SELECT FirstName,LastName,Title,City from employees where city= '" + City + "';select FirstName, LastName from employees where city='" + City + "';";
//SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
DataSet myDataSet2 = new DataSet();
myDataSet2.DataSetName = "Contacts";
mySqlDataAdapter.Fill(myDataSet2);
// Write data to files: data1.xml and data2.xml for comparison.
myDataSet2.WriteXml("c:/temp/ContactList.xml");
mySqlConnection.Close();
}
}
XML FILE OUTPUT
<?xml version="1.0" standalone="yes" ?>
- <Contacts>
- <Table>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
<Title>Sales Manager</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table1>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
</Table1>
- <Table1>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
</Table1>
- <Table1>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
</Table1>
- <Table1>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
</Table1>
</Contacts>
|
|
|
|
|