|
Cory Kimble wrote: In parts of my code I am reading from a file and need to temporarily save the data. Currently I have created some Structures. Is this the best practice or would it be better to do arrays or something else. The reason I picked Structures is because in my code I can easily see that str.Ticket means ticket. If I do an array like arrayString(4) does not tell me what I am grabbing.
I would have gone with a class and created a custom object to do this (easier to serialize the data, etc), but structure will do it trick too. Are you mainly worried about your application speed / performance or more worried about good coding practices?
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Both speed Perfomance and practices.
|
|
|
|
|
Cory Kimble wrote: Both speed Perfomance and practices.
In terms of speed I would say an array would probably be the fastest. In terms of best practices, the prefered way would probably be to create an object for it.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Hi Cory,
Definitely classes and structures, and not heterogenous arrays.
The difference in performance would be only a couple of percent,
the difference in code readability is tremendous.
Once you have defined your classes/structures, if you need many of them.
put them together in either collections or arrays, depending on what kind
of operations you need. If arrays, these would be homogeneous arrays
(each element of the array has the same meaning).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi every one,
I am developing a windows application which needs word and visio application to be embedded on to a form. I am using DSOFramer Active-X control to do the above.
My application reads data from the database (a BLOB Field - that contains the word or visio document) and creates a temporary file in the local directory and then opens that file using DSOFramer control. (http://support.microsoft.com/kb/311765)
All the manipulations are stored on the same temporary file and update the file contents on to that database (as BLOB).
It works fine most of the time but some times while saving the word document it through an exception - "the target of an invocation"
Inner Exception -System.Runtime.InteropServices.COMException (0x80030021): A lock violation has occurred.
This exception occurs while saving the document.
There is an even provided by DSOFramer control – ‘OnSaveCompleted’ which occurs on save completion.
After the file saved, I am opening the temporary file using IO.FileStream and reading the contents to byte() and updating the database with new binary data(BLOB Field)
I hope this explains wat I am trying to do.
Please could any one tell me where I am going wrong.
Thanks in advance
chirantan
|
|
|
|
|
I am trying to update a database in .net. When I created the data source .net copies the database in my project folder to the bin folder. Every time my application runs it copies the database. My application grabs the info and puts it in a dataset that has a filter (Only bring in records where column Loaded equals 'No') I then do a process and set certain records' columns to 'Yes'. When I fill the dataset again it is suppose to take off those records that I changed the columns to 'Yes'. It doesn't. When I look at my folders. The folder in the path of the build did not change. The other did. How do I get rid of one of these databases and make this work, without starting the datasource over?
Any ideas. I hope I explained this well enough.
Also, Why am I getting this error
'C:\Documents and Settings\walz-db.WALZEQ\My Documents\Visual Studio 2005\Projects\VS2005 InYardTrucks\bin\bin\myTest.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
What do I need to change to fix?
-- modified at 10:01 Tuesday 28th August, 2007
|
|
|
|
|
You need to fix whatever code is generating that path string. Somehow, the bin folder has been added twice. We'd need to see the code that's putting this path string together.
|
|
|
|
|
Here is the only place I thing there might be something wrong but don't know how to fix.
When I call the fill:
Me.TransactionTableTableAdapter.Fill(Me.MyTestDataSet.TransactionTable)
It eventually gets to this code in the Settings.designer.vb file
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.SpecialSettingAttribute(Global.System.Configuration.SpecialSetting.ConnectionString), _
Global.System.Configuration.DefaultSettingValueAttribute("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\myTest.mdb")> _
Public ReadOnly Property TestConnection() As String
Get
Return CType(Me("TestConnection"), String)
End Get
End Property
The truth is I don't have a TestConnection anymore. I have a dataBind to the myTest.mdb listed above. Is this my problem?
I will try to put everything here I think is pertinant to solve this problem.
Connection string: Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Documents and Settings\walz-db.WALZEQ\My Documents\Visual Studio 2005\Projects\VS2005 InYardTrucks\myTest.mdb"
datagrid = bindingsource
BindingSource = MytestDataSet
MytestDataSet has two adapters and two tables, one per adapter
I don't know what other lines of code you need.
|
|
|
|
|
Cory Kimble wrote: .SpecialSettingAttribute(Global.System.Configuration.SpecialSetting.ConnectionString), _ Global.System.Configuration.DefaultSettingValueAttribute("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\myTest.mdb")>
This says that if there is a ConnectionString, return it from the settings in your app's settings. If there is no setting available, return the DefaultSettingValue instead. Id' look in your app setting Project/Properties for a value for the connection string.
|
|
|
|
|
So, how do you suggest I solve my issue.
In folder C:\VS2005 InYardTrucks I have a database myDatabase(We will call it Database1). This is where I have the build go to. In C:\VS2005 InYardTrucks\bin there is a copy of myDatabase(We will call Database2). When I do a fill the dataset is filled with the Database1 data. When I update the dataset it writes it to Database2. So When I run the program again Database 1 overwrites anything in database2.
How do I fix? Where do I need to look to find the code that does this? Do I need to change my build location to the bin folder? Do I need to repost this to see if anyone knows?
Thanks.
I found the problem. the database had a output directory property set to 'Always copy' and I changed it to "Never copy'
Thank you.
-- modified at 11:50 Friday 31st August, 2007
|
|
|
|
|
I'm not seeing how this would cause the problem you described. I'm still wondering how you got a bin folder inside a bin folder in your project's directory structure.
|
|
|
|
|
hi
i want to do windows hook programming .i am a beginner and am not able to understand codes given as examples in internet.could any one give me a good example and reference links for doing hooks programming and api programming.
i have to record and replay the keboard and mouse events thats my main requirement.
with regards
Balagurunathan.B
|
|
|
|
|
The terms "beginner" and "windows hook" don't belong in the same paragraph, let alone the same sentance. Windows Hooks are an advanced topic, especailly the CBT hook that you're looking to use.
If you can't understand the stuff you've already found, pointing you to more links probably isn't going to help. Also, how are we going to be able to explain it to you in a much shorter forum post?
This article[^] is about the only one I've found that explains the hook and how to implement it in a managed class. If this goes over your head too, I have no idea how to explain it to you.
|
|
|
|
|
thanks for link .
with regards
Balagurunathan.B
|
|
|
|
|
hi All,
am creating an application to search the Grid, i master that in SQl db, no am using Access for this Application. i have an adapter , at the moment am using a Wizard. and i have this SQl statement that works fine when i run it in Query analyzer, but when i drop it in the Adapter it give the Following Error.
OleDbCommand.Prepare method requires all variable length parameters to have an explicitly set non-zero Size.
Here is an SQl statement in the adapter.
SELECT Actual_Extent, Boundary_Area, Compl_Boundary_Area, Current_Values, Extension, First_Prop_Address, Improved_Value, Improvements_Value, Lis_key, Num_key, Own_Name, Parcel_No, Parcel_Portion_No, Primary_ID, Prop_Address, Purchase_Date, Site_Value, Street_Name, Street_No, Title_Deed_No, Values_Effective FROM Property_ValRoll WHERE
(Boundary_Area = ?) AND
(SUBSTRING(Lis_key , 5 , 5) = ? )
This code is working fine only when i remove the substring search like this
SELECT Actual_Extent, Boundary_Area, Compl_Boundary_Area, Current_Values, Extension, First_Prop_Address, Improved_Value, Improvements_Value, Lis_key, Num_key, Own_Name, Parcel_No, Parcel_Portion_No, Primary_ID, Prop_Address, Purchase_Date, Site_Value, Street_Name, Street_No, Title_Deed_No, Values_Effective FROM Property_ValRoll WHERE
(Boundary_Area = ?) AND
(Lis_key = ? )
but i need to Search within the String. how can i achieve that.
thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
|
|
|
|
|
Am replying to my POst, i have post this same thread in other Forum on the Net and i found that Access(Ole) does not support "substring", i replaced substring with the "mid" function and my adapter was perfectly created. Now from the above query in my adapter i have changed it to
SELECT Actual_Extent, Compl_Boundary_Area, Boundary_Area, Current_Values, Extension, Improved_Value, First_Prop_Address, Improvements_Value, Lis_key, Num_key, Own_Name, Parcel_No, Parcel_Portion_No, Primary_ID, Prop_Address, Purchase_Date, Site_Value, Street_Name, Street_No, Title_Deed_No, Values_Effective FROM Property_ValRoll WHERE (Boundary_Area = ?) AND (MID(Lis_key, 5, 5) = ?)
And now i have a Search button that will search the grid from a selection in the combobox and textbox. here is the code.
Dim strErrorMsg As String
Dim strerror As System.Data.SqlClient.SqlError
Try
damixed.SelectCommand.Parameters("Boundary_Area").Value = cmbboundary.Text
damixed.SelectCommand.Parameters("Lis_key").Value = txterf.Text
damixed.Fill(Dsmixed)
If Dsmixed.Tables("Property_ValRoll").Rows.Count = 0 Then
MessageBox.Show("Township was not found")
Else
Dsmixed.Clear()
damixed.Fill(Dsmixed)
DataGrid1.DataSource = Dsmixed
End If
Catch ExSQL As System.Data.SqlClient.SqlException
''''All this will trap all data Problems and Network if available
For Each strerror In ExSQL.Errors
Next
Select Case strerror.Number
Case 17
strErrorMsg = "Missing server"
Case 4060
strErrorMsg = "Missing database"
Case 18456
strErrorMsg = "Missing user name or password"
Case Else
strErrorMsg = strerror.Message
End Select
MessageBox.Show(strErrorMsg, "SQL Server Error: " & strerror.Number, MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch ExcpInvOp As System.InvalidOperationException
MessageBox.Show("Close the connection first!", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch Excp As System.Exception ' generic exception handler
MessageBox.Show(Excp.Message, "Unexpected Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
When i try to search inserting anput into the textbox , i get the following Error
An OleDBParameter with Parametername 'Lis_key' is Not Containt by this OleDBParameterCollection
i have declared a separate adapter for the combobox "cmbboundary" ,with the following code in it.
SELECT DISTINCT Boundary_Area FROM Property_ValRoll ORDER BY Boundary_Area
What is Wrong with the Parameter that is complaining about
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
|
|
|
|
|
iam validating the textbox in lostfocus event but it is changing values for month to date and viceversa when the day is single digit.
this is the code iam using,please mail how to weite code for validating.thanks
Private Sub txtfromip_LostFocus()
If txtfromip.Text <> "" Then
On Error GoTo errtrap
If Not IsDate(Format(txtfromip.Text, "MM/dd/yyyy")) Then
MsgBox "Invalid Date. Enter Valid Date. Format is 'MM/dd/yyyy'", vbInformation
txtfromip.SetFocus
SendKeys "{home}+{end}"
Else
txtfromip.Text = Format(txtfromip.Text, "MM/dd/yyyy")
End If
Exit Sub
errtrap:
MsgBox Err.Description, vbCritical, "Error No:" & CStr(Err.Number)
Err.clear
End If
End Sub
|
|
|
|
|
You should not use "SendKeys "{home}+{end}"
If you want to select the textbox content try this:
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
|
|
|
|
|
I m trying to connect to the SQL Server 2000 installed in a network machine n have tried to connect with the following connection string:
conn.Open "Provider=SQLOLEDB" & _
";Data Source=192.168.0.5,1433" & _
";Network Library=DBMSSOCN" & _
";Initial Catalog=" & "master"
But i have an error as below;
Runtime-error '-2147467259 (80004005)'
Invalid authorization specification
Pls help me wats goin wrong.
raamay
|
|
|
|
|
|
You are not specifying the security options.
For NT Authentication:
"provider=sqloledb;Data Source=SERVER;Initial Catalog=DATABASE;Integrated Security=SSPI;"
For Sql Authentication:
"provider=sqloledb;Data Source=SERVER;Initial Catalog=DATABASE;UID=SA;PWD=Pass"
|
|
|
|
|
Yes i added the security options and now i get the error 'SQL Server doesnot exist or access denied' . I m sure the connection string is okey but i doubt we need to configure SQL Server and its remote access properties which i dont find plus dont have any idea what to do & wat to change. So, u got da idea i wud b immensely grateful.
raamay
|
|
|
|
|
That looks like a conection problem,
First try to ping the server from Dos by it's name, it should at least resolve it's ip address
Then from the client machine try this:
Start
Run
CliConfg
And then set the "Default network library" to "TCP/IP"
If it still not working try
Telnet Server 1433
If it says that could not connect, then you have a network problem!
-- modified at 12:00 Wednesday 29th August, 2007
|
|
|
|
|
thanx n i tried every thing as u suggested. i tried pinging n it works plus moved to the second step whereby the Default network library is already set to "TCP/IP". And the 3rd one, there is no msg at all. it starts by saying connecting to the server and then disappears.
infact i wanted 2 say tht my network is a very small network n i m 100% confident it doesnt 've a problem. Probably i think i must use Sql Server authentication because during installation, i made the all authentication based on windows. Plus, i get the error "Login failed for user 'server\Guest'" now. i tried the sa login but failed to connect.
Any way thanks 4 ur support, pls lemme know further if u get any ideas.
raamay
|
|
|
|
|
Hi
I am generating a word document in visual basic.Net. I need to know how can i add header and footers in document programatically. Also there is a picture in it i want to set its layout programatically
Salman Sheikh
|
|
|
|
|