|
Here's my delima. I have a web form that inserts data into a SQL database via a stored procedure. I have 64 columns per row. The data can only be inserted/viewed but not deleted or updated. Is there a better way of updating 64 fields without having to assign the value of Textbox.Text directly? Here's what I'm doing it currently:
submitEPARControl.ascx.vb (Fieldnames changed for security):
Private Sub lbSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbSubmit.Click
Dim newRow As DataRow
Dim strUIC As String
Dim ds As New DataSet
Dim di As New DataInterface
If Page.IsValid Then
ds = di.CreateEmptyDataSet
ds.Tables(0).TableName = "Table"
newRow("Field1") = Field1.Text
newRow("Field2") = Field2.Text
newRow("Field3") = Field3.Text
ds.Tables(0).Rows.Add(newRow)
di.AddData(ds)
Else
End If
End Sub
DataServices.vb:
Public Function AddData(ByRef dsAddition As DataSet)
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim dbCommandWrapper As DBCommandWrapper = db.GetStoredProcCommandWrapper("MyStoredProc")
dbCommandWrapper.AddInParameter("@Field1", DbType.String, "Field1", DataRowVersion.Proposed)
dbCommandWrapper.AddInParameter("@Field2", DbType.String, "Field2", DataRowVersion.Proposed)
dbCommandWrapper.AddInParameter("@Field3", DbType.String, "Field3", DataRowVersion.Proposed)
Return db.UpdateDataSet(dsAddition, dsAddition.Tables(0).TableName, dbCommandWrapper, Nothing, Nothing, UpdateBehavior.Continue)
End Function
- Paul Davis
|
|
|
|
|
I don't know for sure, but it looks like your adding the data to your DataTable object, then writing that same data back to the database using a stored procedure. Could you get away with just adding the data to the database with the stored procedure, then reload your DataTable? If the data you're retrieving is small enough this wouldn't be a problem. But if your DataTable holds thousands of rows, how your doing it would probably be the best way.
In either case, you can't do it with less code. And frankly, from what you've posted, I don't think your using enough code! Are you validating and normalizing your data before you add it to the database or are you letting your stored procedure add it?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
At this point, the application is not in production. I have not yet added the validation code. However, that is my next step if this way of adding the data is the final way.
All my background is with unix/windows applications (mostly C/C++). Guess I was hoping for a cleaner way of doing it using bindings since I'm only adding one row at a time. I will be moving the commandwrapper to the submit event and add the data using the StoredProcedure directly as you suggested. That will clean up some.
Thank you for the response!
- Paul Davis
|
|
|
|
|
hi guys,
i've datagrid in my windows form and i've implemented combobox in one of the datagrid column. Now my problem is tht when i click on tht text of the comboboxcolumn it converts into dropdown and if i click it again it opens and show me all the available values. so in this case to see and select the value i have to click it twice. but i need to do it with one click. how can i do tht.
Or there is an another option but i dont know how to implement it. it is like when i bind my grid every row should have the combobox for a perticular column. ie. every combo should remain forever unlike in the normal case when it comes only when u try to edit a perticular row.
plz give me some solution..
thnx in advance
A R MOGHE.
|
|
|
|
|
...so in this case to see and select the value i have to click it twice. but i need to do it with one click. how can i do tht.
i've never done but try to handle the "VisibleChanged" event in your columnstyle and popup the combobox.
...it is like when i bind my grid every row should have the combobox for a perticular column. ie. every combo should remain forever unlike in the normal case when it comes only when u try to edit a perticular row.
your DatagridComboboxColumn has one instance of your combobox and shows it until one cell will be edited. if you like to show the combobutton in each cell of your column you have to draw it you own. you can use
system.Windows.Forms.ControlPaint.DrawComboButton
in your onPaint method
good luck
|
|
|
|
|
Thanks buddy for ur kind information, i really appriciate ur help..
A R MOGHE.
|
|
|
|
|
The project I am working on was built to be used in conjunction with a touchscreen, but due to cost, it now has to work with a regular keyboard and mouse as well. Due to the nature of the project, I have to be able to prevent a user from leaving the application and having access to windows.
How would I capture keys such as Ctrl+Alt+Delete and prevent the default behavior? I will also need to prevent Alt+Tab, the windows key, etc.
I believe I know how to do the capture....
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
'Ctrl keypress
If e.KeyChar = ChrW(17) Then
'then what?
End If
End Sub
Really going to need some help here..
Has anyone done something similar?
|
|
|
|
|
Have also tried:
If Control.ModifierKeys = Keys.ControlKey Then<br />
e.Handled = True<br />
Microsoft.VisualBasic.Interaction.Beep()<br />
End If<br />
If Control.ModifierKeys = Keys.Alt Then<br />
e.Handled = True<br />
Microsoft.VisualBasic.Interaction.Beep()<br />
End If<br />
If Control.ModifierKeys = Keys.Control Then<br />
e.Handled = True<br />
Microsoft.VisualBasic.Interaction.Beep()<br />
End If<br />
If Control.ModifierKeys = Keys.Escape Then<br />
e.Handled = True<br />
Microsoft.VisualBasic.Interaction.Beep()<br />
End If<br />
If Control.ModifierKeys = Keys.RWin Then<br />
e.Handled = True<br />
Microsoft.VisualBasic.Interaction.Beep()<br />
End If<br />
If Control.ModifierKeys = Keys.LWin Then<br />
e.Handled = True<br />
Microsoft.VisualBasic.Interaction.Beep()<br />
End If
but the default behavior still runs
|
|
|
|
|
There is no way to stop Ctrl-Alt-Delete or Alt-Tab or any other system combination from popping up from your code. Those key combinations are handled by the system before your app even knows that the final key in the combination was even pressed. For example, your app will known that Ctrl and Alt are held down, but will never see the Del key. It will know that Alt is down, but not the Tab key.
Most of these things are best handled by modifying Group Policy on the machine. Some, like disabling the Windows key are better left to a C++ app that uses a low-level keyboard hook and eats certain keys.
Still, there's no way to stop Ctrl-Alt-Del from popping up. But, by using Group Policy, you can stop everything the user can do in the dialog that pops up. I would HIGHLY suggest picking up the Resource Kit for what OS your using for your kiosk. It'll prove to be invaluable in a case like this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Found an article on Managing Low-Level Keyboard Hooks in VB .NET:
http://www.developer.com/net/vb/article.php/10926_2193301_3[^]
The code works great... but needs some working on..
I am currently using it to successfully block:
Ctrl+Escape
Alt+Tab
Alt+Escape
Alt + F4
And the Right/Left Windows keys
Just need to get Ctrl+Alt+Delete...
I don't doubt that "key combinations are handled by the system before your app even knows that the final key in the combination was even pressed" , but somehow this module seems to work, doing just that(?).
Maybe if you had a look at the article?
|
|
|
|
|
I know for a fact that there is absolutely no way on earth you're going to trap Ctrl-Alt-Delete. Unless of course, you replace the GINA.DLL (don't even bother). You can't stop it from popping up, but you can block the actions that can be taken inside the dialog using Group Policies (Start/Run - gpedit.msc.)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yeah, was just reading that on MSDN....
Gina isn't an option....
now have to modify the registry...
Ugh
HKCU\
Software\
Microsoft\
Windows\
CurrentVersion\
Policies\
System\DisableTaskMgr = dword:1
thanks
|
|
|
|
|
Hi All,
Could anybody help me out in identifying the association between the
.NET's ReleaseComObject() method and the Dispose Pattern? Are they are
similar things and serves the same purpose. Are they substitute of each
other?
This issue has become really hot for our project. Itwill be really
great if the xpert people can provide their corresponding usage for
real world applications. Differences/ Similarties between them and what
exactly they serves?
Please share your expertise and provide me some good database of
knowledge.
Thanks in advance.
Deeps
|
|
|
|
|
Dispose gives a MANAGED object (any class you write) the opportunity to clean up and free any resources that it needs to before the object is detroyed. For some classes, this isn't necessary. For others, this is a necessity. For instance, creating a FileStream object opens an unmanaged file handle allocated by the system. If you didn't call the Dispose, or Close, method on the FileStream object, the object would eventually be destroyed, when it falls out of scope, and the underlying file handle orphaned, causing a resource leak. Eventually, you could consume thousands upon thousands of file handles, never releasing them back to the system (Windows) and eventually crashing it.
The very same thing can happen with COM object that you wrap with .NET classes. If your .NET class creates an instance of a COM object, it also has to release that instance, using ReleaseComObject, when it's done. Usually, this is done inside the Dispose method of your class.
DeepakSharma wrote:
Are they substitute of each
other?
Not just no, but HELL NO. Dispose and ReleaseComObject deal with entirely different objects and situations. They are by no means interchangable.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks a lot for your descriptionn. It really helped me a lot in understanding the concept.
Regards
Deeps
|
|
|
|
|
I need to create dbf file format with vb.net,please tell the way.
Thank for your help.
|
|
|
|
|
|
There are 10 different applications that use that file extension (as told by the FilExt database). Which one of those are you talking about?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I will use the dbf file with dbfrom for windows.
|
|
|
|
|
i wan to interface the sound card in pc with the visual basic 2005 express edition, is it work?And where can i find the sound library before i start programming? i search for long and can't find it in any website.
i wan use the visual basic 2005 express edition to do a digital signal processing project which related to memory pointer, it it work? Or other software is more suitable?thx for your help.
|
|
|
|
|
Sure it'll work. You just need the right SDK for what your doing. DSP is a really vague description though.
If you have a SoundBlaster, go to http://www.creative.com[^] and click the Developers link. You'll find the SDK there. If you don't have a SoundBlaster, go to the site for your sound cards manufacturer. I'm sure you'll find an SDK for your card.
Microsoft has DirectSound, part of DirectX. You can download the DirectX SDK from the DirextX Developer Center on MSDN, here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Helllo
I am using a datagrid in a web application(.NET). When an user clicks the grid I want an menu to appear, (something like windows right click). I was thinking of creating the menu and all the functionallity in VB 6.0 ActiveX, and importing the ocx into the web app and using it there...
Will this work?
Is there an better way to solwe this problem?
Spaz
|
|
|
|
|
Spaz80 wrote:
Will this work?
Yeah. It's overkill and the browser will have to download and install your component.
Spaz80 wrote:
Is there an better way to solwe this problem?
JavaScript.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi guys... need serious help with this..
i was reading the source codes at
http://www.codeproject.com/vb/net/epsendmail.asp
and i know that to send emails, you need to have an SMTP server. However, where i'm studying there isn't an SMTP server available.
I was wondering, is it possible to use a server such as the QKSoft free SMTP servers? If so, what do i need to enter under the "SMTP Server --->" fields?
Secondly, this particular code enables the user to send emails using the command prompt. Unfortunately i need to do it on VB.net, so what modifications do i need to make to the codes to convert it into a VB.net program rather than a command prompt one?
Lastly, which email address can i use for the "from" field? i don't think i can use some web-based email such as hotmail or gmail, right? so what can i enter in this particular field? if i were to use something like an ISP email address, won't i need to log in using my username and password first?
Thanks so much for your help guys... this project's killing me!
|
|
|
|
|
This is the code for email in VB.Net
imports system.collections
imports system.componentmodel
imports system.data
imports system.drawing
imports system.web
imports system.web.sessionstate
imports system.web.ui
imports system.web.ui.webcontrols
imports system.web.ui.htmlcontrols
imports system.web.mail
imports system.configuration
Private Sub btnsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsend.Click
Server.ScriptTimeout = 1000
Response.Flush()
Dim smtp As SmtpMail
smtp.SmtpServer = "localhost"
Dim mail As MailMessage
mail = New MailMessage
mail.To = txtto.Text
mail.From = txtfrom.Text
mail.Cc = txtcc.Text
mail.Bcc = txtbcc.Text
mail.Subject = txtsubject.Text
mail.Body = txtbody.Text
Try
smtp.Send(mail)
MsgBox("The Mail Has Been Send Successfully")
Catch ex As Exception
MsgBox("Error: " & ex.Message)
End Try
Response.Flush()
End Sub
|
|
|
|