|
If you are getting a Timeout Error, do the Following
checkCmd1.CommandTimeout = 0
This will allow your command object to run until the job is done.
Hope it Helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hai friends
i want to add few images(pictureboxes) to the TableLoutPanel control at run time.
in the direction ...
like this..
--------->
1 2 3 4 ...
this the direction and the number 1,2,3,4.. are the labels indicationg the index of the images/picture boxes.
i m new to this control ....
plz help me
thanks in advance
vijay
|
|
|
|
|
You may use TableLayoutPanel1.Controls.Add method to add controls in a cell of control.
Number of rows and columns can be controled using RowCount and ColumnCount property.
Followign code will show you 4 cells with 4 pictureboxes in it –
---------------------------------------------------
Me.TableLayoutPanel1.RowCount = 1
Me.TableLayoutPanel1.ColumnCount = 4
Me.TableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.InsetDouble
Dim colno, rowno As Integer
colno = 0
rowno = 0
For i As Integer = 0 To 3
Dim picBox As New PictureBox()
picBox.BackColor = Color.Yellow
Me.TableLayoutPanel1.Controls.Add(picBox, colno, rowno)
colno += 1
Next
-------------------------------------------------
I hope this helps.
-Ajay.
-------------------------
www.componentone.com
-------------------------
|
|
|
|
|
|
Do you get any error messages?? "It won't run" doesn't give us anything to go on...
As speculation... Did you copy EVERYTHING from the Release fodler of your app to the other machine, or just the .EXE??
|
|
|
|
|
Sorry. No error messages, just no go. Nothing happens at all. The other machine is using the 'built' release version which you install with an installer. He has the very latest version.
Also, if I unregister the DLL, I can break it on my machine.
|
|
|
|
|
hi
i want to create a security policy setup and to deploy that setup on my client machines via domain so that i could run dotnet application from my lan without any security exception.
but i am unable to create any setup like that ,please help , any link or helping stuff ,,
thanks in advance
hello
|
|
|
|
|
|
I added a student to the database when in debug mode, but when I exit out of debug mode and then go back into debug mode the new student record is not there.
Do you know why? Do I need to commit the changes to the database? I am using acceptChanges.
I also add lesson information for the student. When I try to add the lesson information it doesn't even add to the database. Why does the student add but not the lesson?
When I used a message box to display the lesson info it displayed.
Here is my code to add the student.
addRow = lpDataSet.tbl_students.Newtbl_studentsRow()
addRow("stud_name") = txtStudentName.Text
addRow("stud_par_name") = txtParentName.Text
addRow("stud_add") = txtStudAdd.Text
addRow("stud_unit_num") = txtAptNum.Text
addRow("stud_city") = txtCity.Text
addRow("stud_state") = txtState.Text
addRow("stud_zip") = Convert.ToInt32(txtZip.Text)
addRow("stud_email") = txtEmail.Text
addRow("stud_cell") = txtStudCell.Text
addRow("stud_phone") = txtStudPhone.Text
addRow("stud_status") = intStudStat
lpDataSet.tbl_students.Rows.Add(addRow)
studTableAdapter.Update(addRow)
lpDataSet.Tables("tbl_students").AcceptChanges()
Here is the code to add the lesson.
addRow = lpDataSet.tbl_lessons.Newtbl_lessonsRow()
addRow("less_instrument") = txtInstrument.Text
addRow("stud_id") = Convert.ToInt32(cboSelectStudent.SelectedValue)
addRow("less_start_date") = Convert.ToDateTime(dtpStartDate.Text)
addRow("less_end_date") = Convert.ToDateTime(dtpEndDate.Text)
addRow("less_time") = Convert.ToDateTime(lvwItem.SubItems(1).Text)
addRow("less_day") = intDay
addRow("teach_id") = Convert.ToInt32(cboSelectTeacher.SelectedValue)
addRow("less_status") = intLessStat
lpDataSet.tbl_lessons.Rows.Add(addRow)
lessonTableAdapter.Update(addRow)
lpDataSet.Tables("tbl_lessons").AcceptChanges()
|
|
|
|
|
You're using an Access database as the datastore, correct?
In your project, under the Solution Explorer, you should find your .MDB file somewhere. Click on it and, in the Properties window, you should find an option called "Copy to Output Directory". If this is set to "Copy always", Visual Studio is copying your test database to the Debug or Release folder every time you run your app. This copy is what your code is modifying. The next time you to run your app, the original database file you created is copied to the Debug or Release folder again, overwriting anny changes your code made during the previous run.
|
|
|
|
|
I have a list view and when the user selects an item in the list view there is a combo box that has a list of teacher names in it. I am trying to pre select a teacher name when the user click on the item in the list view, but the teacher name is not changing when the user clicks on the item in the list view. I hard coded a selectedValue which is the teacher id to see if the teacher name would change in the combo box and it did.
Here is my code. Why is this happening?
Private Sub lvwSelectLess_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles lvwSelectLess.MouseDown
grpBxLessonInfo.Visible = True
Dim dt As New DataTable()
Dim lvwItems As New ListViewItem()
Dim selection As ListViewItem = lvwSelectLess.GetItemAt(e.X, e.Y)
If (selection IsNot Nothing) Then
MsgBox(selection.SubItems(4).Text)
cboSelectTeacher.SelectedItem = selection.SubItems(4).Text ' this si the line of code to set a pre selected item in the combo box.
txtInstrument.Text = selection.SubItems(3).Text
lblStartDate.Text = selection.SubItems(5).Text
dtpEndDate.Text = selection.SubItems(6).Text
End If
End Sub
|
|
|
|
|
AAGTHosting wrote: cboSelectTeacher.SelectedItem = selection.SubItems(4).Text ' this si the line of code to set a pre selected item in the combo box.
By setting the Text property of the ComboBox, you're not actually selecting anything. All you're doing is putting text in a TextBox control. To select the item, you have to call the FindString method of the ComboBox to find the text of the item you're looking for. This will return the index of the first item that matches that string. It'll return -1 if the item is not found. Then you can set the SelectedIndex property of the ComboBox to select the item.
|
|
|
|
|
I am trying to modify an XML node, such as the following example:
<url>http://www.codeproject.com
I have created a System.Xml.Xmldocument, and traversed the file using Xml.Xmlnodelist, Xml.Xmlelement and Xml.Xmlnode and want to replace some text.
I do this by using the InnerText property of the XmlNode and then call the following method:
XmlDocument.WriteTo(XMLTextWriter)
...where XMLTextWriter is the same file opened with the XMLDocument, which throws a file in use error.
Is there any way that I can modify the XMLDocument whilst it is still loaded in memory?
Matt
|
|
|
|
|
Have you tried the Save method of the XmlDocument class??
|
|
|
|
|
Using XmlDocument.Save throws the same error - file is in use by another process
|
|
|
|
|
What does the code look like that's loading the XML document?? Save and WriteTo both work on a document that's been loaded by XmlDocument.LoadXml, so this has to be caused by some other reader or permissions issue.
|
|
|
|
|
Right now, the code is:
Dim CurDir As String = Environment.CurrentDirectory() & "\globalConfig.xml"
Try
Dim sr As New System.IO.StreamReader(CurDir)
Dim globalConfig As Xml.XmlDocument = New Xml.XmlDocument()
globalConfig.Load(CurDir)
Dim buildingList As Xml.XmlNodeList
Dim root As Xml.XmlElement = globalConfig.DocumentElement
buildingList = root.SelectNodes("/config/buildings/name")
Dim info As Xml.XmlNode
' xml text writer - used for writing for xml document
For Each info In buildingList
If info.InnerText = buildingName Then
info.NextSibling.InnerText = resource
End If
Next
globalConfig.WriteTo(CurDir)
[...]
I shall using XmlDocument.LoadXML...
Matt
|
|
|
|
|
OK. We'll start with line number 1:
CocaColaBoy wrote: Dim CurDir As String = Environment.CurrentDirectory() & "\globalConfig.xml"
Bad idea. CurrentDirectory is NOT a static directory. Annyone who's ever just thrown around an OpenFileDialog knows that the current directory can change at any time. A more proper method is to use a well-known folder that doesn't change, like Application.StartupPath . Also, don't use string concatenation to build paths, use something that's designed for the task:
Dim filePath As String = Path.Combine(Application.StartupPath, "globalConfig.xml")
CocaColaBoy wrote: Dim sr As New System.IO.StreamReader(CurDir)
Dim globalConfig As Xml.XmlDocument = New Xml.XmlDocument()
globalConfig.Load(CurDir)
Dim buildingList As Xml.XmlNodeList
...
Yikes. You're opening a file on the first line of this section, but never using it, nor ever CLOSING it either. This is where your problem originated from. Then, in the next line, you're using the XmlDocument.Load method to grab the contents of the .xml file. You can have two processes (or the same process in this case) both read the same file at the same time, but writing to an already open file usually requires exclusive access to the file. In your case, you've guaranteed that exclusive access is impossible by putting creating the StreamReader instance at the top of your code.
|
|
|
|
|
Dave Kreskowiak wrote: OK. We'll start with line number 1
I'm guessing I've headed in the wrong direction? Hmmm... not a good start.
The purpose of using Environment.CurrentDirectory is that the location of this application will vary somewhat. Would:
Dim filePath As String = Path.Combine(Application.StartupPath, "globalConfig.xml")
...achieve the same thing?
Basically I am trying to update an XML document that is opened in:
Dim globalConfig As Xml.XmlDocument = New Xml.XmlDocument()
globalConfig.Load(CurDir)
...and, yeah, now you point this out, filePath would definitely been a much better name!
I guess my next question would be: how do I open an XML file for exclusive access? Would this allow for read/write access. I'm guessing so?
|
|
|
|
|
OK... so I now have working what I wanted in the first place... and I want to thank you for your help.
Anyhow, for reference purposes, here is the working code:
Public Function setBuildingInfo(ByVal buildingName As String, ByVal resource As String) As String
' create and open XML document
Dim CurDir As String = Environment.CurrentDirectory() & "\globalConfig.xml"
Try
'Dim sr As New System.IO.StreamReader(CurDir)
Dim globalConfig As Xml.XmlDocument = New Xml.XmlDocument()
globalConfig.Load(CurDir)
Dim buildingList As Xml.XmlNodeList
Dim root As Xml.XmlElement = globalConfig.DocumentElement
buildingList = root.SelectNodes("/config/buildings/name")
Dim info As Xml.XmlNode
' xml text writer - used for writing for xml document
For Each info In buildingList
If info.InnerText = buildingName Then
info.NextSibling.InnerText = resource
End If
Next
Dim writeDocument As Xml.XmlTextWriter = New Xml.XmlTextWriter("globalConfig.xml", _
System.Text.Encoding.Unicode)
globalConfig.WriteTo(writeDocument)
writeDocument.Close()
Catch ex As Exception
MessageBox.Show(Err.Description())
End Try
End Function
Where buildingName is what is being searched for in the document and resource is the replacement text!
Matt
|
|
|
|
|
CocaColaBoy wrote: I guess my next question would be: how do I open an XML file for exclusive access? Would this allow for read/write access. I'm guessing so?
They invented a couple of things called documentation and Google, so you can come up with
all the questions you want, and have a pretty good chance of finding the answers yourself
in a matter of minutes.
Have a look at the File.Open Method (String, FileMode, FileAccess, FileShare)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
CocaColaBoy wrote: The purpose of using Environment.CurrentDirectory is that the location of this application will vary somewhat. Would:
Dim filePath As String = Path.Combine(Application.StartupPath, "globalConfig.xml")
...achieve the same thing?
The problem with using CurrentDirectory is that the current directory can change during the execution of your app. Application.StartupPath always points to the folder your .EXE was launched from.
CocaColaBoy wrote: I guess my next question would be: how do I open an XML file for exclusive access? Would this allow for read/write access. I'm guessing so?
XmlDocument.Load only opens the file for shared read, share deny write, for as long as it needs to read the entire file. When the document is done loading, the file is closed.
If you wanted to retain an exlusive (basically share deny all) lock on the file, you'd have to open it using a FileStream instance. FileStream lets you specify a shared access setup when you create the filestream instance. You could then pass that stream the the XmlDocument.Load method to laod the document. Just remember to Seek the filestream back to position 0 before you try to write the XML back to the file, and, of course, close the filestream when your done.
|
|
|
|
|
I'm wondering which account to run my vb.net windows service under to allow it access to a server. I assume it's "user" but cant test it at the minute. Is there another way to allow this?
|
|
|
|
|
You have to use a user account that has access permissions to the network. There's no way around this. An application or service runs AS the user that launched it. Whatever permissions the user account has, that's what the application gets access to.
|
|
|
|
|
figured as much. Thanks anyway for the quick response!
|
|
|
|