|
This is more of a SQL question.
I have come across this situation myself and my suggestion is to try and detach and then re-attach the database in Enterprise Manager - this sometimes fixes the issue.
I don't want to recommend deletion of log files etc as I don't want to be held responsible for loss of data.
Googling the issue bought this up:
A database can be marked for many reasons. Generally it falls into the following conditions :
* A database or log file is missing.
* In SQL 6.5, a device may not be present or in 7.0/2000 a file may not exist.
* SQL Server may not have been able to restore the database in ample time.
* The database could be corrupt.
* The database is being help by the operating system. This could be a 3rd party backup software or defrag software. I've had even a virus scanning software cause this once.
* SQL Server does not have enough space to recover the database on startup.
You always pass failure on the way to success.
|
|
|
|
|
what r the properties to change the progressbar forecolor and backcolor
|
|
|
|
|
There are no properties for this. If you want to change the appearance of the ProgressBar, you're going to have to create your own version of it. Create a new class that inherits from ProgessBar and add the properties and code for BackColor, ForeColor, and all the drawing code to custom draw the control.
|
|
|
|
|
Hola,
I am working on a tool that from one side connects to a simulation model using ActiveX and to the other side to a control system via Sockets.
The only thing the tool should do is making connections to both parties (simulation model and real controls) and send message through between the two components.
For the socket side of the tool I made this code with a lot of copy pasting from websites (see below). But it doesnt work... A connection is made, but receiving and sending is not working. I dont understand what to do with the receive function (which parameters). I only want to receive a string (size 100) through the connection. Sending seems to work because the real controls get stuck when I call the SendMessage sub.
Another question is how I can automatically react on a incoming message instead of checking this every 0.1 sec (I call the sub every 0.1 sec). Is there an event defined that wakes up when incoming data arrives?
Please help.
Imports System<br />
Imports System.Text<br />
Imports System.IO<br />
Imports System.Net<br />
Imports System.Net.Sockets<br />
Imports Microsoft.VisualBasic<br />
<br />
Public Class MySockets<br />
<br />
Dim Listener As Socket<br />
Dim Sender As Socket<br />
Public Function ConnectSocket(ByVal server As String, ByVal port As Integer) As Socket<br />
<br />
<br />
Listener = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)<br />
<br />
' bind the listening socket to the port<br />
Dim hostIP As IPAddress = Dns.Resolve(IPAddress.Any.ToString()).AddressList(0)<br />
Dim ep As New IPEndPoint(hostIP, port)<br />
Listener.Bind(ep)<br />
<br />
' start listening<br />
Listener.Listen(1)<br />
<br />
Sender = Listener.Accept()<br />
<br />
Return Sender<br />
End Function<br />
<br />
Public Sub SendMessage()<br />
<br />
Dim Data As String<br />
Data = "HolaHola"<br />
<br />
Dim msg As Byte() = System.Text.Encoding.ASCII.GetBytes(Data)<br />
<br />
Debug.Print(Sender.Connected)<br />
Sender.Send(msg)<br />
End Sub<br />
<br />
Public Sub ReceiveMessage()<br />
Dim vbBytes As Int32<br />
Dim buffer As Byte()<br />
Dim vsString As String<br />
vbBytes = Listener.Receive(buffer)<br />
<br />
vsString = Encoding.ASCII.GetString(buffer, 0, vbBytes)<br />
End Sub<br />
End Class
|
|
|
|
|
Nasbcn wrote: I made this code with a lot of copy pasting from websites (see below). But it doesnt work...
The problem with copy'n'paste coding is that you have little to no understanding of the code, how it works, or why. This alone makes it impossible for you to support the code. When something breaks, you're utterly lost.
Using a Timer to call anyof this code is a really bad idea. You've got no control over the flow of the code and the data it's carrying.
Here's[^] a good example of how it should be done. You should study the Server side of this code.
|
|
|
|
|
Hi All
i have a Function in my Component(DAL), the Function Accept an intiger value and return a dataset.
<br />
<br />
Public Function Search_lis(ByVal lis_key As Integer) As Dssearchlis<br />
<br />
dasearchlis.SelectCommand.Parameters.Add(lis_key)<br />
dasearchlis.Fill(Dssearchlis)<br />
If Dssearchlis.Tables("Property_Mass").Rows.Count = 0 Then<br />
MsgBox("Township not Found")<br />
Else<br />
Dssearchlis.Clear()<br />
dasearchlis.Fill(Dssearchlis)<br />
<br />
End If<br />
Return Dssearchlis<br />
End Function<br />
Am Calling this Function in my Form. like this
Dim objsearch As New PropDAL.Properties
Dim dsdata As New PropDAL.dssearchlis
Dim txtseachlis As Integer
txtseachlis = Val(txtlisSearch.Text)
Dim strErrorMsg As String
Dim strerror As System.Data.SqlClient.SqlError
Try
dsdata = objsearch.Search_lis(txtseachlis)
dgr.DataMember = "Property_Mass"
dgr.DataSource = dsdata
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
What is Wrong , and what should i put in mind when dealing with parameters, i know i should have used a storedProcedure, but for now i need to use this.
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Should this not be in the coding horrors forum?
|
|
|
|
|
This code has so many problems, I don't know where to start...
First, you've made a VB.NET 101 mistake. You're returning an object of type Dssearchlis , which is also the name of an apparently "global" object. It get the feeling that you're returning the exact same object that is already visible outside the function, making retuning the object pointless.
|
|
|
|
|
Hi I want to disable/ enable my save all button if changes exist in the datagridview. Where would I need to put the code and what does that code typically look like? Thanks in advance. Im aware that I have to set the button to "enabled = false" but where? and how do I check for changes?
Mr Oizo
|
|
|
|
|
hi
Try this
If DataSet111.HasChanges = True Then
btnSave.Enabled = true
else
btnsave.Enabled = False
end if
hope it helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Handle the DataGridView's CurrentCellDirtyStateChanged event. Then the code would probably look something like:
If DataGridView1.IsCurrentCellDirty Then
' Enable save changes button.
End If
Do NOT put in code to disable the button! Once a cell is dirty, consider the entire dataset dirty, even if this cell is changed back to it's original value!
|
|
|
|
|
Ok thanks for the help. you say I shouldn't disable the save button at all but I seem to get data cncurrency errors in my code when I save the same values twice. What happens is that an autonumber is generated for each song in my song library whena new song is added and when i call savechanges it gives me a concurrency error if i hit save twice in a row. so I just wanna disable that button when they have already pressed save and if they edit further then re-enable the button. Any ideas where to put the code?
Mr Oizo
|
|
|
|
|
Mr Oizo wrote: but I seem to get data cncurrency errors in my code when I save the same values twice.
OK. Obviously, you can reset the save button AFTER the changes are saved. Come on, think!!
|
|
|
|
|
I think i have a big problem with my program.I have sat for 3 weeks with this data concurrency error and I can't fix it. it is happening in a project i'm writing for my thesis and at the moment i'm gonna fail just because this is stopping me from continuing with the rest of my project. the problem is that I can add data to a dataset but as soon as I try to edit the newly added data and save a data concurrency error appears(o records updated out of the expected 1 record(or similar to that)). I have read tons of articles and still can't find the problem. It's a single user environment, my dataset tables and database tables have the same field types and everything. the update statement looks fine. the only thing that i can assume is wrong is something to do with the fact that i have a datagridview and several textboxes bound to the underlying dataset and when I call "saveChanges" it tries to save the values from both the textbox for the column and the datagridview for the column. the only code used by my textboxes and datagrid is databinding code eg:
modbdaSongNewest2.ClearBeforeFill = True<br />
modbdaSongNewest2.Fill(DsLibraryNewest2.Song)<br />
<br />
' bindingSong is a bindingsource object<br />
<br />
bindingSong.DataSource = DsLibraryNewest2<br />
bindingSong.DataMember = "Song"<br />
<br />
<br />
dgSongProperties.DataSource = bindingSong
txtArtist.DataBindings.Add("Text",bindingSong, "Artist",_<br />
True, DataSourceUpdateMode.OnPropertyChanged)
When adding new songs to the library I use the Openfiledialog and run a for loop for each file that was selected and add rows using this code which is pretty standard:
Dim FileInfo As System.IO.FileInfo ' This variable will hold the selected file info<br />
Dim drCurrentSong As dsLibraryNewest2.SongRow<br />
<br />
If Not (dlgOpenFile Is Nothing) Then<br />
<br />
<br />
For i = 0 To dlgOpenFile.FileNames.GetUpperBound(0)<br />
FileInfo = My.Computer.FileSystem.GetFileInfo(dlgOpenFile.FileNames(i))<br />
' This will retrieve the foldername for the file<br />
Dim folderPath As String = FileInfo.DirectoryName<br />
' MsgBox(folderPath)<br />
' This will retrieve file name for the file<br />
Dim fileName As String = FileInfo.Name<br />
'MsgBox(fileName)<br />
<br />
' This will retrieve the full path of the file <br />
Dim absolutePath As String = FileInfo.FullName<br />
' MsgBox(absolutePath)<br />
<br />
Try<br />
drCurrentSong = DsLibraryNewest2.Song.NewSongRow<br />
<br />
With drCurrentSong<br />
<br />
.FileName = fileName<br />
.FolderPath = folderPath<br />
.AbsolutePath = absolutePath<br />
<br />
End With<br />
DsLibraryNewest2.Song.AddSongRow(drCurrentSong)<br />
' Call SaveChanges()<br />
<br />
Catch ex As System.ArgumentException<br />
DsLibraryNewest2.Song(mintCurrent).CancelEdit()<br />
<br />
Catch ex As System.Data.ConstraintException<br />
MessageBox.Show( _<br />
ex.Message, _<br />
"Error", MessageBoxButtons.OK)<br />
DsLibraryNewest2.Song(mintCurrent).CancelEdit()<br />
<br />
End Try<br />
mintCurrent += 1<br />
Next<br />
<br />
End If<br />
<br />
<br />
End Sub
anyway that code all works fine. the problem is editing the data not adding it. So the only code I have for editing is the binding bit in the from load event and this bit:
Private Sub dgSongProperties_RowLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgSongProperties.RowLeave<br />
<br />
' this line below doesn't really do anything <br />
<br />
dgSongProperties.Update()<br />
<br />
End Sub<br />
<br />
<br />
<br />
<br />
<br />
<br />
Private Sub BindingSource1_BindingComplete(ByVal sender As Object, ByVal e As System.Windows.Forms.BindingCompleteEventArgs) Handles bindingSong.BindingComplete<br />
<br />
'the following code Checks if the data source has been updated, and that no error has occured.<br />
If e.BindingCompleteContext = BindingCompleteContext.DataSourceUpdate _<br />
AndAlso e.Exception Is Nothing Then<br />
<br />
' If not, end the current edit.<br />
e.Binding.BindingManagerBase.EndCurrentEdit()<br />
<br />
End If<br />
<br />
<br />
End Sub
i know you are really busy and I have probably just left something out or forgot to call something. My other forms all work correctly and update their data but this one with the datagridview that has textboxes bounded to the datatable has a problem? if you can help me then please do... time is running out for me. thank you
Mr Oizo
|
|
|
|
|
Guy, I can't tell you how to unravel this because your code is a pile of spaghetti. What we tell you to change in one place breaks something in another. We can't see the entire picture of what's going on from a few code snippets. This is a much larger design issue than it is a "simple fix" because you forgot something.
|
|
|
|
|
|
Dave Kreskowiak wrote: Come on, think!!
Pbbbbbbbbt. Why would they do that, that's why they're asking questions in the CP forums...
Sigh..
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
How read a txt file in visual basic & convert a Ms-Access.
Any body help me urgent
send a source code
|
|
|
|
|
Gagan Deep Garg wrote: How read a txt file in visual basic & convert a Ms-Access.
You've already asked this question once today and been given an answer. Why have you chosen to ignore the advice given to you?
Gagan Deep Garg wrote: Any body help me urgent
You've already been told that it is rude to say this in your posts. Why did you not listen?
Paul Marfleet
|
|
|
|
|
Reposting the same question again and again in the same day will not get you any code written for you.
You have to read the file, line-by-line, parse each line to get the data you want, then execute an INSERT query on your database.
For reading the file, see the File class. For parsing the line you read, the String class' Split method. For database access, the classes in the System.Data.OleDb namespace.
|
|
|
|
|
How to send a picture throught Winsocket in VB 6.0,
woukd i get any sample on it...
Rajasekar
|
|
|
|
|
Since VB6 is a dead language and support for it is waning fast, this[^] is about the best anyone can do for examples.
|
|
|
|
|
Dave Kreskowiak wrote: support for it is waning fast
What do you mean waning fast? My company is still using it to create projects...
Mike Lasseter
|
|
|
|
|
I should have clarified that with "Web support for it"...
mr_lasseter wrote: My company is still using it to create projects...
You have my sympathies. I know all too well what it's like to be forced to do things today, the way the industry did it 10 years ago.
|
|
|
|
|
hi
i want to make a grid item as browsable one so i can select a file through open filedialog and set its path for the item. how i can achieve this could any one give me sample code.
with regards
Balagurunathan.B
|
|
|
|