|
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
|
|
|
|
|
You'll have to explain this a bit more.
The PropertyGrid will only show the properties of an instantiated object. This means you'd have to load the assembly, give the user a list of possible classes to use, create an instance of that class, then bind the PropertyGrid to it.
|
|
|
|
|
Hi All
Am new to this subject of Patch files. i have Built Windows Applications and they work fine. Now one of my Clients want to add a Functionality to the Existing Windows Application that i have design before. So i thought of a Patch File but now i have never built something like that before. So basically i need a Tutorial or an Article or Advice on how to build Patchfiles if its the right way to go. if there is another solution, i will greatly Apreciate it
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
|
|
|
|
|
depends on what needs to be done and how big you'r programme is
but for almost every programme you can follow the following procedure:
just code the additional functionality into the original project then build and at client side you can just replace the exe and dll files (perhaps with a batch file) and the functionality will be implemented into the application.
if you don't use class projects in you don't need to replace dll's (you probably will not have any)
if all you change is a form then replacing the exe file will be enough
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Thank you, TDDragon
i get your Point
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
|
|
|
|
|
I have frmMainPage on my project which control everything. Also I have some button on frmMainPage when I click btnMember a form will be loaded on panel2 on frmMainPage( like callfrmMember. I have alredy done this with DAVE's help)
Now frmMember is loaded on frmMainPage in panel2.
Question1: At that moment if I click btnAddNewBook then a Message will be come like msgbox("Please Close Existing Form before you want to open another window") not the frmMainPage.
Question2: on frmMember i have a btnShowDetails when I will click this button then frmMemberDetails will load on frmMainPage on Panel2
Thank You
Sarfarj Ahmed
|
|
|
|