|
Is it necessary for you to have an autonumber field as a key in your table ? if not, u can write ur own code for auto-incrementing the id and for this, u can modify ur database and change the key field to a normal id. As far as i think auto-number fields are generated automatically when u insert the record, but u certainly can retrieve the id for viewing purpose.
|
|
|
|
|
|
Hi,
I am using streatchblt() and SetStretchBltMode() functions of unmanaged code in C# for printing image. For doing that I am calling the external gdi32.dll (form windows folder) file.
I am new in doing this sort of platform invoke operation. Plz tell me if my software is run in any windows version ranges form windows 95 to vista or any upcoming version, will this be problematic?
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
<br />
static extern bool StretchBlt(IntPtr hdcDest, int nXOriginDest, int nYOriginDest,int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, Int32 dwRop);<br />
<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
<br />
static extern bool SetStretchBltMode(IntPtr hdc, int iStretchMode);
>> I have tried to add this dll file as a reference in my code but failed to do so as this file is unaccessible.
Plz tell me if I have any alternative for doing the work of the above mensioned functions with managed code.
thanks in advance
Faysal
|
|
|
|
|
No, StretchBlt has been there forever. Goodness knows why you're using it tho. You can set the draw mode of GDI+ stretch drawing in C#.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
As far as I know there is no function like stretchblt() or SetStretchBltMode() in C#. And if I try to change the resolution of my image according to my printer's device context then it gets too slow without showing any apperant change in the print quality.
Plz tell me if you know about any such function in C# or any other way to obtain a better print out quality of image in C#. (I really want to avoid unmanaged code in C#)
Faysal
|
|
|
|
|
The Graphics object has DrawImage, most of hte overloads let you resize the image.
There are overloads that take an ImageAttributes object, you either set the stretch mode there, or there's a property on the Graphics object to set the stretch mode.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi im trying to remove an element from a single dimension array and i heard the only way to do this is sort of a wrap around, but im not to sure on how to approach this. I know its easy using Array Lists but i cant use that for what i am trying to do, any help would be appreciated
|
|
|
|
|
What? So like:
1
2
3
4
5
and you remove '2' and end up with
1
3
4
5
null
?
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Why wouldn't a List work?
|
|
|
|
|
im not saying that a list wouldn't work but for what im doing i can only do the array
|
|
|
|
|
My question still stands, why can't you use a List? A list is basically a array whose size can change. You can add arrays to the list and turn the list into an array.
|
|
|
|
|
You can't change the size of an array. You have to create a new array and copy the items that you want to keep from the old array.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
when creating a data base in a c# application from the solution it self, there be a data set generated with it , it contains three files one of them is .xsc and other is .xss
I was wonder if there are some tutorials to learn how possible can I get benefit of that ,
and I need to learn what are the possible connection string format for the data base
thanks in advance
There is always something to learn
|
|
|
|
|
Again with the sockets jordan?! Yep. On the host end I have a List of sockets:
<br />
List <socket> sockets = new List <socket> ();<br />
Now when I get the "OnAccept" callback I add the new socket to the list mentionned above*. When the host closes the form, I iterate through each Socket in the list. What I want to know is how to disconnect and shutdown a socket properly, as well as for the Client. The client has only one socket.
There is Socket.Disconnect (bool reuse), Socket.Shutdown (SocketShutdown how) and Socket.Close () and I'm confused what I'm supposed to use and in what order. I suspect all three in the order that I mentionned.
*
<br />
private void OnAccept (IAsyncResult ar)<br />
{<br />
Socket new_socket = connection_starter.EndAccept (ar);<br />
sockets.Add (new_socket);<br />
<br />
connection_starter.BeginAccept(whatever, null, void, foo, bar);<br />
}<br />
Thanks.
modified on Wednesday, April 23, 2008 4:32 PM
|
|
|
|
|
|
Yay I'm not get SocketExceptions anymore! Thanks.
|
|
|
|
|
Hello,
I am trying to import a csv file. I know my code works because I have imported may files. but my problem is if the file name has a ' or a second . in the name I get a Syntax error in FROM clause.
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source={0};Extended Properties={1}Text;Excel 8.0;HDR=No;{2}",
System.IO.Path.GetDirectoryName(FileName), (char)34, (char)34);
conn.open();
string SchemeFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(FileName),
"schema.ini");
if (File.Exists(SchemeFile))
File.Delete(SchemeFile);
using (FileStream SchemaStream = new FileStream(SchemeFile, FileMode.CreateNew))
{
using (StreamWriter writer = new StreamWriter(SchemaStream))
{
writer.AutoFlush = true;
writer.WriteLine("[" + System.IO.Path.GetFileName(FileName) + "]");
writer.WriteLine("ColNameHeader=False");
writer.WriteLine("Format=Delimited(,)");
writer.WriteLine("CharacterSet=ANSI");
writer.WriteLine("Col1=Code text width 255");
writer.WriteLine("Col2=Description text width 255");
writer.WriteLine("Col3=UnitOfMeasure text width 255");
writer.WriteLine("Col4=Price text width 255");
}
SchemaStream.Close();
}
CommandText = String.Format("SELECT * FROM {0}", System.IO.Path.GetFullPath(FileName));
OleDbDataAdapter da = new OleDbDataAdapter(CommandText, conn);
DataTable MyTable = new DataTable();
da.Fill(MyTable);
it crashes on the last line the da.fill
Any help would be wonderful
Thanks
|
|
|
|
|
Replace ' with '' in your string, otherwise SQL sees it as a constant string value, just like using double quotes when defining a string in code.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: Replace ' with '' in your string, otherwise SQL sees it as a constant string value, just like using double quotes when defining a string in code.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
I am sorry...
I forgot to mention.
I had already tried doing the FileName.replace("'", "''");
I have also tried making the entire FileName wrapped in " " and I have also tried making it so the entire path was wrapped in double quotes.
Any other thoughts?
|
|
|
|
|
I'd break it up so the path is built as a string first, then step through and look at what that string is to try to work out what's going wrong.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Just wanted to give everyone an update. I have figured out how to get a file to import if the file name has a single quote in the name. The way to do this is to put [] around the file name
string test = String.Format("Select * from [{0}]", System.IO.Path.GetFileName(FileName));
However having a period in the name is still breaking the code. I am still working at figuring out that and having the muliple quotes on the csv.
here is an example of the file
1234, "Bar, Energy", 2
1457, """Bar, Candy""", 1.50
the first line in the table would look like column a 1234, column b Bar, Energy, column c 2.00
but the second line should be column a 1457, column b "Bar, Candy", 1.50
But it is crashing the import saying Syntax error in from clause
|
|
|
|
|
Hi there!
I'm coding a windows application with VS 2005 Express edition.
The application has only a DataGrisView to show the Customers table of Northwind database. (Very simple)
When I try to add the database source for the DataGridView, and add a new connection in the wizard, I select the Northwind database, then I select "Use SQL Server Authentication" and set the "User Name" and "Password".
When I try to "Test Connection", the connection fail with the following message:
Failed to generate a user instance of SQL Server. Only an integrated connection can generate a user instance.
If I use "Use Windows Authentication" (Integrated connection and authentication) there is no problem.
In the other hand, If I use the "SQL Server Management Studio", I can login with those user name and password in order to see Northwind database.
How can I use SQL Server Authentication in the application?
Thank you in advance.
--
Adrián Córdoba
|
|
|
|
|
Can you create a new ConnectionString and then use the same in your app. instead of using it at design time.
If this still does not work, then post your ConnectionString here. However, please make sure of these three points:
1) You are missing the User Instance=true clause, which tells SQL Express to spin up a separate process for the ASP.NET account, eliminating the need to explicitly grant permission to ASP.NET. Note that you should never grant sysadmin priviledge to the ASP.NET worker process, since that is a very priviledged permission level.
2) You should be using the |DataDirectory| variable in place of the fully-qualified path to the database, for example: |DataDirectory|\<mdf_filename>.MDF
3) MACHINENAME must be local when using SQL Express. Consider using .\SQLExpress for the machine name.
Best Regards,
Sam Xavier
www.componentone.com
|
|
|
|
|
OK, Thank you for your answer.
I tried by modifying the connection string in this way:
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Archivos de programa\Microsoft SQL Server\MSSQL.1\MSSQL\Data\northwnd.mdf";Persist Security Info=True;User ID=northwind;Password=PASSWORD;Connect Timeout=30;User Instance=True"
but I get the same connection error, when I run the application from "Start Debugging" button from Microsoft Visual C# 2005 Express Edition.
May be, Express Edition doesn't allow SQL Server Authentications.
Anyway, I don't know about SQL Server security, but I think when I deploy the application, I should use an "Application Role".
Do you know, where can I read about Application Roles, and how I have to use it?
Thank you, again.
--
Adrián Córdoba
|
|
|
|
|
Have you already modified machine.config file appropriately. If no, then please modify it like this:
All the providers' default configurations point them to use the connection string named "LocalSqlServer" which is defined in the "machine.config" file which lives in the framework config directory. In this file, you shoud modify your connectionstring like the following in the connection strings section:
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" .../>
Best Regards,
Sam Xavier
www.componentone.com
|
|
|
|