|
That's a very generic question covering an awful lot of ground. To start with, just open the VB6 project in Visual Studio 2005. Do not double click the projects .VBP file. You have to open Open the Project with VS2005 already started. This will automatically launch the upgrade wizard which will TRY AND DO ITS BEST to convert the code to VB.NET. Since there are lots of changes between VB6 and VB.NET code, chances are you WILL have errors and need to correct the code by hand to get it working.
|
|
|
|
|
Hi,
Please help me...
I am struggling to run more then one query on sql server 2005... i get errors and i dont really know how to get going.
Here is what i have tried now:
<br />
Dim mySQLConnection As New SqlConnection( _<br />
"Initial Catalog=DBName;Data Source=InstanceName;Integrated Security=SSPI;")<br />
mySQLConnection.Open()<br />
<br />
Dim mySQLTransaction As SqlTransaction = _<br />
mySQLConnection.BeginTransaction()<br />
<br />
Dim mySQLCommand As SqlCommand = _<br />
mySQLConnection.CreateCommand()<br />
<br />
mySQLCommand.CommandText = "SELECT * FROM StagingEmployer ORDER BY StagingDate"<br />
<br />
mySQLTransaction.Commit()<br />
<br />
mySQLConnection.Close()<br />
Now... how do i get the Select * from StagingEmployer Order by StagingDate return values into a rowset that i can use???
Once there... how do i run a second query like for instance:
<br />
Update StagingEmployer<br />
Set EndDate = GetDate()<br />
Where StagingDate < '2007/01/01'<br />
Sorry... i have tried it but not like this... i can post my previouse attempt but i will do this in 2nd post... it is a bit large.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
See: here i tried to run second query but no success with this:
<br />
Dim connectionString As String = "Initial Catalog=DBName;Data Source=InstanceName;Integrated Security=SSPI;"<br />
Dim cn As SqlConnection = New SqlConnection(connectionString)<br />
Dim sqlCommand As SqlCommand = New SqlCommand("SELECT * FROM StagingEmployer ORDER BY StagingDate", cn)<br />
cn.Open()<br />
Dim TestRowset As SqlDataReader = sqlCommand.ExecuteReader()<br />
<br />
While TestRowset.Read()<br />
If (Convert.ToString(TestRowset(35)) = "U") Then<br />
Dim sqlCommand2 As SqlCommand = New SqlCommand("UPDATE stagingEmployerTest SET" _<br />
+ " [Employer_Number] = '" + Convert.ToString(TestRowset(0)) _<br />
+ "', [Name] = '" + Convert.ToString(TestRowset(1)) _<br />
+ "', [Trading_Name] = '" + Convert.ToString(TestRowset(2)) _<br />
+ "', [Business_Number] = '" + Convert.ToString(TestRowset(3)) _<br />
+ "', [Company_Number] = '" + Convert.ToString(TestRowset(4)) _<br />
+ "', [Tax_File_Number] = '" + Convert.ToString(TestRowset(5)) _<br />
+ "', [Street_Address_1] = '" + Convert.ToString(TestRowset(6)) _<br />
+ "', [Street_Address_2] = '" + Convert.ToString(TestRowset(7)) _<br />
+ "', [Street_Address_3] = '" + Convert.ToString(TestRowset(8)) _<br />
+ "', [Street_Suburb] = '" + Convert.ToString(TestRowset(9)) _<br />
+ "', [Street_State] = '" + Convert.ToString(TestRowset(10)) _<br />
+ "', [Street_Postcode] = '" + Convert.ToString(TestRowset(11)) _<br />
+ "', [Street_Country] = '" + Convert.ToString(TestRowset(12)) _<br />
+ "', [Postal_Address_1] = '" + Convert.ToString(TestRowset(13)) _<br />
+ "', [Postal_Address_2] = '" + Convert.ToString(TestRowset(14)) _<br />
+ "', [Postal_Address_3] = '" + Convert.ToString(TestRowset(15)) _<br />
+ "', [Postal_Suburb] = '" + Convert.ToString(TestRowset(16)) _<br />
+ "', [Postal_State] = '" + Convert.ToString(TestRowset(17)) _<br />
+ "', [Postal_Postcode] = '" + Convert.ToString(TestRowset(18)) _<br />
+ "', [Postal_Country] = '" + Convert.ToString(TestRowset(19)) _<br />
+ "', [Contact_Name] = '" + Convert.ToString(TestRowset(20)) _<br />
+ "', [Contact_Title] = '" + Convert.ToString(TestRowset(21)) _<br />
+ "', [Contact_Salutation] = '" + Convert.ToString(TestRowset(22)) _<br />
+ "', [Phone] = '" + Convert.ToString(TestRowset(23)) _<br />
+ "', [Fax] = '" + Convert.ToString(TestRowset(24)) _<br />
+ "', [Email] = '" + Convert.ToString(TestRowset(25)) _<br />
+ "', [Broker] = '" + Convert.ToString(TestRowset(26)) _<br />
+ "', [Underwriter] = '" + Convert.ToString(TestRowset(27)) _<br />
+ "', [Diplomatic_Indemnity] = '" + Convert.ToString(TestRowset(28)) _<br />
+ "', [Status] = '" + Convert.ToString(TestRowset(29)) _<br />
+ "', [Image] = '" + Convert.ToString(TestRowset(30)) _<br />
+ "', [Created] = '" + Convert.ToString(TestRowset(31)) _<br />
+ "', [Created_By] = '" + Convert.ToString(TestRowset(32)) _<br />
+ "', [Modified] = '" + Convert.ToString(TestRowset(33)) _<br />
+ "', [Modified_By] = '" + Convert.ToString(TestRowset(34)) _<br />
+ "', [Action] = '" + Convert.ToString(TestRowset(35)) _<br />
+ "', [StagingDate] = '" + Convert.ToString(TestRowset(36)) + "'" _<br />
+ " WHERE [Employer_Number] = '" + Convert.ToString(TestRowset(0)) + "'", cn)<br />
sqlCommand2.ExecuteScalar()<br />
End If<br />
MsgBox("Result :" + Convert.ToString(TestRowset(35)))<br />
End While<br />
In this example the first Query is the Select * from StagingEmployer Order By StagingDate (this one works fine) the second Query is the Update... (not working) i posted this section before but without the ,cn in the 2nd query. Sorry.
This doesnt work???
I thought it should and i am not sure why and how to get this going? Sorry for the big post.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Okay, i see that it is advised to use the ExecuteNonQuery() rather than ExecuteScalar() in my second query (the update Query)... but it is still not working
It gives an error : There is already an open DataReader associated with this Command which must be closed first.
I think i know what it means but i don't know how to fix it... The TestRowset is still open (i think that is why the error comes up) but i can't close it right??? because it needs to read it to be able to go to next record and next record and so on???
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Beside your error I give you the tip to exlude the database connections and the SQL code OUTSIDE your code. SQL code belons in stored procedures and db connections in a ini-file or registry. This enables changes outside your code if there are db changes so a normal user/db-admin can modify it.
Greetings from Germany
|
|
|
|
|
okay, thanks... i will keep that in mind... i will change it when i get this working
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
hi guys,,
i want my application to run from my network in partial trust mode and also i want to access data with oledbpoviders but i get security exception if i am in partial trst mode unless i configured the intranet zone to full trust that what i dont want, is there any way that i can run this application in partial trust mode, how do i create custom permission set like stuff ,, thanks in advance
..
hello
|
|
|
|
|
this is rather complicated stuff (more administrator like )
Normaly the best way is to give your application a strong name and then use the .net MMC plugin to configure the security context for the signed assembly.
|
|
|
|
|
can u please explain in a brief detail or give me some helping link ..
thanks in advance
hello
|
|
|
|
|
To use the .net config tool just go to the command prompt and enter:
"mscorcfg.msc"
You will see a nice GUI and hopefully find the infos you need.
To sign a assembly you can use sn.exe to generate a public/private-key that you can use in your application
More help with google:
http://www.google.com/search?q=code+security+.net
This one seems a good start:
http://msdn.microsoft.com/msdnmag/issues/01/02/CAS/
As I said: this stuff is rather nasty - to fully understand you might want to buy a book (there are several books - just search for security and .net - I think any of these will have one or more chapters concerning CAS)
|
|
|
|
|
how can i convert dataset to datatable or how can i copy dataset to datatable?
thanks in advance!
jyn
modified on Wednesday, January 09, 2008 7:41:18 PM
|
|
|
|
|
jhyn wrote: how can i convert dataset to datatable
DataTable dt = ds.Table[0];
jhyn wrote: how can i copy dataset to datatable?
DataSet ds = new DataSet();<br />
ds.Tables.Add(dt);
|
|
|
|
|
A DataSet is a collection of DataTable objects with any DataRelation objects connecting the tables. There's no such thing as converting a DataSet to a DataTable. The table you want is already a member of the DataSet.
|
|
|
|
|
hi,
i have two question:
1-
i move from form to another by function show() and hide() ,how can backtracking to first form or refresh first form ?
2-
how can delete row from sql server 2005 after 24 hours ?
|
|
|
|
|
break_day wrote: how can delete row from sql server 2005 after 24 hours ?
You can use either windows service or winform with timer control.
break_day wrote: i move from form to another by function show() and hide()
show() and hide() function is not for moving.
break_day wrote: how can backtracking to first form or refresh first form ?
Not sure what you meant.
|
|
|
|
|
ok, how can i move from form to another in my project ?
|
|
|
|
|
Are you doing to do something like wizard? if yes, you can use frame or groupbox in one form. (for example, frame1 is showing by default. if the user clicks on "Next" button, you can hide the frame1 and show the frame2.)
|
|
|
|
|
but if the user clicks on "back" button ?
|
|
|
|
|
break_day wrote: but if the user clicks on "back" button ?
then, you can hide the frame2 and show the frame1. it's simple, isn't it?
|
|
|
|
|
but if change in form1 and hide it and show form2 and then show form1 the changes in form1 stay in it ?
|
|
|
|
|
You didn't get what he said. You don't use multiple forms. You use ONE form with multiple Panel controls on it, one on top of the other, with each Panel hosting the controls for one page of your "wizard".
|
|
|
|
|
Hi..
Im having an unusal problem when printing the string i pass printpage handler to the drawstring..
dim i as integer
dim stringtest as string
e.g. for i=0 to 8000
stringtest = stringtest & "TESTING" & vbnewline
next i
so the for loop will return 8000 TESTING each with a newline in it..
like :
TESTING
TESTING
TESTING....
(8000) total..
then i fire the printpage handler to measure and drawstring as needed...but i get a problem which is if i have 2000 or less it draws on the first and every page correctly but if i have more records in the string e.g. 5000... then it will print 10 blank pages and then show the rest of the records after that..
is there a real limit as too how much data one can store in a string at all ????????? is that the problem.. im really lost ..
any help would be appreciated..
hope i was clear
Regards
Robbo
modified on Wednesday, January 09, 2008 2:05:12 PM
|
|
|
|
|
Hi,
I suspect you are victim of some 16-bit limitation inside GDI+, your string probably has a
length of 72K chars.
Is it really necessary to create such a large string? Why would you have to print
everything using just one string? Why not use just "TESTING" inside a for loop?
|
|
|
|
|
Hi Luc
Thanks for your reply. so whats the best way to do this.. i know theres a better way to hold data and send to print etc ... but my programming skills arent there yet.. what do you propose i do.. is there a way i can check the string if it has reach max size and then create a new string etc..
i'd appreciate any advice you have ..ive literally googled everywhere and found example out of my scope when it comes to printing properly ... i know people use array's etc.. what do you propose and a helpful and not to heavy example would be much appreciated.
kind regards
Robbo
|
|
|
|
|
Hi,
DrawString takes many parameters, including the string text, and a pair of coordinates.
So why not organiza a loop (for, or while), and call DrawString many times, each time
with the same string (just "TESTING" would do), but with different coordinates?
The only drawbacks I can see is:
1. when you rely on DrawString to do word wrapping for you, then it needs all the wrappable
text at once; but for text lines of less than 10 chars each, this does not apply, does it?
2. when you rely on DrawString to do pagination for you, then it again needs all the
text at once; but that is not how pagination should be handled; you really need to
take care of coordinates yourself, and as soon as y reaches the bottom of the page,
tou should remember your position in the document, print the current page, and when
the next PrintPage event occurs, continue where you left off. Of course, if all your
pages are to be identical, you can just print N pages with L lines of text.
(You would need PrintPageEventArgs.HasMorePages no to ask for another page...)
BTW: if printing seems to complicate matters for you, you can do exactly the same
when painting text onto a Panel on screen...
modified on Thursday, January 10, 2008 10:37:38 AM
|
|
|
|