|
DocId data type is text in my database
|
|
|
|
|
What is the actual definition for DocId in your database schema? Also why are you calling ToString on the Me.RefferencNoTxt.Text object; is it not already text?
Use the best guess
|
|
|
|
|
Beiniam wrote: i can't add all characters except integers in the database column DocId. it accepts only integer values. so how can i insert characters in the DocId filed.
From that it makes me ask the question is the column type numeric? (integer, decimal etc.)
you will need to convert RefferencNoTxt.Text to the correct numeric type that your database needs.
i.e.
dim value as integer = Convert.ToInt32(RefferencNoTxt.Text)
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Your code is a classic example of SQL Injection[^]. One mis-placed ' in a text box, and your entire database could be corrupted.
Change the code to use parametereized queries instead:
cmd.CommandText = _
"INSERT INTO EraDms(DocId, Description, Address, NoOfPages, SendOrReceived, SentDate, ReceivedDate, ForwardedWorkingUnit, Attachements, ForwardedDate, ReceivedBy, DocPath) " & _
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
cmd.Parameters.AddWithValue("@p0", Me.RefferencNoTxt.Text)
cmd.Parameters.AddWithValue("@p1", Me.DescriptionTextBox.Text)
cmd.Parameters.AddWithValue("@p2", Me.AddressTextBox.Text)
cmd.Parameters.AddWithValue("@p3", Me.NoOfPagesTextBox.Text)
cmd.Parameters.AddWithValue("@p4", Me.SendOrReceievedComboBox.Text)
cmd.Parameters.AddWithValue("@p5", Me.SentDateTextBox.Text)
cmd.Parameters.AddWithValue("@p6", Me.receivedDate.Text)
cmd.Parameters.AddWithValue("@p7", Me.ForwardedWorkingUnitTextBox.Text)
cmd.Parameters.AddWithValue("@p8", Me.AttachementsTextBox.Text)
cmd.Parameters.AddWithValue("@p9", Me.TextBox6.Text)
cmd.Parameters.AddWithValue("@p10", Me.ReceivedByTextBox.Text)
cmd.Parameters.AddWithValue("@p11", Me.DocPathTextBox.Text)
And:
cmd.CommandText = _
"UPDATE Eradms " & _
" SET Description = ?, " & _
" Address = ?, " & _
" NoOfPages = ?, " & _
" SendOrReceived = ?, " & _
" SentDate = ?, " & _
" ReceivedDate = ?, " & _
" ForwardedWorkingUnit = ?, " & _
" Attachements = ?, " & _
" ForwardedDate = ?, " & _
" ReceivedBy = ?, " & _
" DocPath = ? " & _
" WHERE DocId = ?"
cmd.Parameters.AddWithValue("@p0", Me.DescriptionTextBox.Text)
cmd.Parameters.AddWithValue("@p1", Me.AddressTextBox.Text)
cmd.Parameters.AddWithValue("@p2", Me.NoOfPagesTextBox.Text)
cmd.Parameters.AddWithValue("@p3", Me.SendOrReceievedComboBox.Text)
cmd.Parameters.AddWithValue("@p4", Me.SentDateTextBox.Text)
cmd.Parameters.AddWithValue("@p5", Me.receivedDate.Text)
cmd.Parameters.AddWithValue("@p6", Me.ForwardedWorkingUnitTextBox.Text)
cmd.Parameters.AddWithValue("@p7", Me.AttachementsTextBox.Text)
cmd.Parameters.AddWithValue("@p8", Me.TextBox6.Text)
cmd.Parameters.AddWithValue("@p9", Me.ReceivedByTextBox.Text)
cmd.Parameters.AddWithValue("@p10", Me.DocPathTextBox.Text)
cmd.Parameters.AddWithValue("@p11", Me.RefferencNoTxt.Text)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank you a lot
Richard Deeming eming for your help. it works
|
|
|
|
|
I'm trying to create a utility to perform a mass update of our Active Directory and all I get is the error, "Server is unwilling to process request."
Below is my code:
Dim de As New DirectoryEntry("GC://DC=us,DC=myCompany,DC=com", "myDomain\MyAdminUsername", "myPassword")
Dim ds As New DirectorySearcher(de)
ds.PropertiesToLoad.Add("department")
ds.SearchScope = SearchScope.Subtree
Dim ue As New DirectoryEntry
ds.Filter = String.Format("(SAMAccountName={0})", Me.tboxUserName.Text)
Try
ue = ds.FindOne.GetDirectoryEntry
For Each sproperty As String In ue.Properties.PropertyNames
debug.print(String.Format("{0}{1} : {2} ", System.Environment.NewLine, sproperty, ue.Properties(sproperty)(0)))
Next
If (ue.Properties.Contains("department")) Then
ue.Properties("department").Value = "IT"
Else
ue.Properties("department").Add("IT")
End If
ue.CommitChanges()
ue.RefreshCache()
ue.Close()
Catch ex As Exception
debug.print (ex.Message)
End Try
The code seems to connect to the LDAP server and retrieve the correct user because I can see valid data being displayed from the ue.Properties.PropertyNames collection.
The error is thrown on the "CommitChanges()" line.
BTW: This demo program is a WinForms .NET 4.0 applicaiton
I have tried it passing no credentials and passing valid domain credentials and I get the same " ... unwilling to process request." error.
What am I doing wrong?
|
|
|
|
|
According to http://forums.asp.net/t/1809557.aspx/1[^], the problem arises by using the wrong protocol:
Dim de As New DirectoryEntry("GC://DC=us,DC=myCompany,DC=com", "myDomain\MyAdminUsername", "myPassword")
replace that with
Dim de As New DirectoryEntry(@"LDAP:\\DC=us,DC=myCompany,DC=com", "myDomain\MyAdminUsername", "myPassword")
|
|
|
|
|
Thank you so much. My program is now working.
I've been trying so many combinations that I must have overlooked the obvious.
|
|
|
|
|
This question is a new post prompted by my other thread, "The old DoEvents and UserControls". I created a separate thread here, since it is branching off from the old discussion.
In the other thread, it was looking like converting code from supporting DoEvents, to supporting threading might be a big rewrite. But now I am not so sure. I downloaded an example Pause/Resume Thread program from online and that program had a separate class that was threaded. It then communicated to the main form via a delegate.
But I wanted to find out if it was possible to do threading of a procedure that was NOT in a separate class...But one residing in the main form's class, like any other sub. The reason this was important to me, was to cut down on the amount of code rewriting by keeping my existing code in place, and merely adding on additional code to thread one of those main form procedures. My revision to that original threading example seems to say, "yes", to that question. Here is my version of that little demo. It simply runs a counter that counts from 1 to whatever, and when the thread is suspended, the counter halts, until resumed. Since I am new to threading, is there anything wrong with this idea that could end up biting me in the rear?
Here is the code:
Imports System.Threading
Imports System
Public Class Form1
Private Delegate Sub DisplayValueDelegateType(ByVal txt _
As String)
Private m_DisplayValueDelegate As DisplayValueDelegateType
Private m_Thread As Thread
Public Value As Integer = 0
Public Sub DisplayValue(ByVal txt As String)
txtResults.Text = txt
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim new_counter As New Counter(Me, my_number:=1)
m_Thread = New Thread(AddressOf new_counter.Runno)
m_Thread.IsBackground = True
m_Thread.Start()
Button1.Enabled = False
Button2.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
If (m_Thread.ThreadState And ThreadState.Unstarted) _
<> 0 Then
m_Thread.Start()
Else
m_Thread.Resume()
End If
Button1.Enabled = False
Button2.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
Debug.WriteLine("Suspending thread")
m_Thread.Suspend()
Button1.Enabled = True
Button2.Enabled = False
End Sub
Public Sub DoSomething(ByVal m_MyForm As Form1, _
ByVal m_DisplayValueDelegate _
As Object)
For loopo = 1 To 10000000
Thread.Sleep(3000)
SyncLock m_MyForm
m_MyForm.Value = m_MyForm.Value + 1
If m_MyForm.InvokeRequired() Then
m_MyForm.Invoke(m_DisplayValueDelegate, _
Str(m_MyForm.Value))
End If
End SyncLock
Next loopo
End Sub
Private Sub Quit_cmd_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Quit_cmd.Click
End
End Sub
End Class
Public Class Counter
Private m_MyForm As Form1
Private Delegate Sub DisplayValueDelegateType( _
ByVal txt As String)
Private m_DisplayValueDelegate As DisplayValueDelegateType
Private m_Number As Integer
Public Sub New(ByVal my_form As Form1, _
ByVal my_number As Integer)
m_MyForm = my_form
m_Number = my_number
m_DisplayValueDelegate = AddressOf _
m_MyForm.DisplayValue
End Sub
Public Sub Runno()
Try
Call Form1.DoSomething(m_MyForm, m_DisplayValueDelegate)
Catch ex As Exception
Debug.WriteLine("Unexpected error in thread " & _
m_Number & vbCrLf & ex.Message)
End Try
End Sub
End Class
|
|
|
|
|
treddie wrote: I wanted to find out if it was possible to do threading of a procedure that was NOT in a separate class
No need to test. Yes, you can thread just about any code you want. A form is just a class, like any other.
treddie wrote: The reason this was important to me, was to cut down on the amount of code
rewriting by keeping my existing code in place, and merely adding on additional
code to thread one of those main form procedures.
Wrong approach. If your going to go through the trouble of threading the code, scrap what you have and do it write instead of trying to Frankenstein a solution together.
|
|
|
|
|
But the example program I showed does basically what I'm suggesting. So it doesn't SEEM like a kludge. Especially since all I basically have is one procedure that I need to thread, and everything else is called from it sequentially. So from a performance point of view, it all has to work sequentially anyway, so my only benefit from threading is to have the ability to pause execution at will, which was the primary reason to begin with. Is that a reasonable enough reason for doing it that way? I don't see any future versions of this program gaining any other benefits from threading.
|
|
|
|
|
Hey guys,
I want to connect my VB.NET application to the data saved on my webserver's mysql database. Can you please tell me, is it possible or not? Can you give me any hint for further coading? Where should i look for help in this regard?
Or should I consider other language for this pupose?
[Project Details:]
I want users to fill their info on online php form, this info get saved in mysql database. Now i want to insert this info in the .net application's database installed on client's computer.
|
|
|
|
|
Hi again.
I am curious about a problem I am having with DoEvents. Now, I know DoEvents() is old school, and was only included in vb6 because vb6 did not support threading, at least not without a lot of difficulty. But the problem I have, is that I have ported a vb6 program over to vb.Net and there were a fair amount of DoEvents() lines due to a bunch of loops. These DoEvents lines were necessary because I had a Pause button that needs to stop execution when the user desires it.
This worked OK in .Net, too...Until I included a TreeView usercontrol. Now, a fair amount of time is spent in the usercontrol since as the program scans folders, the TreeView is constantly updating to show the progress. In itself, that is a very inefficient way to show progress due to the amount of time processing the TreeView updates. But it looks rather cool as it progresses and I want to keep that look. The problem is that, I know that threading is the way to handle interruption of processing, but on the other hand, I just want this thing running as quickly as possible with the DoEvents lines...I can switch over to threading at some later date.
But no matter where I put the DoEvents lines, they do not let the Pause button Click event to fire. My question is, does entering a usercontrol cause DoEvents in the stack to get cleared out? Or does it simply disregard any DoEvents lines altogether, whether they are inside the user control or not?
Many thanks for any help on this.
|
|
|
|
|
All DoEvents does is process any pending windows messages sitting in the apps window message queue. It's not a second message pump, but it does suspend everything in the UI thread and handles the remaining messages, then it lets UI thread processing resume as normal.
There is a difference though. The old VB6 DoEvents called Thread.Sleep, where as the .NET implementation does not.
I'd serisouly consider scrapping the DoEvents stuff as soon as possible and transfer the long-running work to either background threads, BackgroundWorker, or Tasks. Doing so will take a considerable rewrite of your code.
|
|
|
|
|
Dave Kreskowiak wrote: Doing so will take a considerable rewrite of your code.
That is exactly what I am concerned about. I am trying to get out a v1 with as much speed as possible, w/o rushing to miss errors in the code.
Dave Kreskowiak wrote: All DoEvents does is process any pending windows messages sitting in the apps window message queue.
That is where my question lies, and I am just as much academically interested in why it is not working, as I am trying to get v1 out the door.
Since the Pause button click is an event, DoEvents SHOULD catch that event sitting in the stack waiting to be processed. Unless something is throwing it out. Could the problem be that every time I pass through the usercontrol, any DoEvents processed there for the Pause button in the UI are ignored? In other words, in trying to get my UI's Pause button to respond to DoEvents in the usercontrol, is it of no use in the usercontrol since it is occurring inside a different class and not the general UI where the Pause button is located?
|
|
|
|
|
The problem is in the code that is looking for the flag to tell it to pause.
The convesion from VB6 to .NET does NOT guarantee that the code is going to run like it did under VB6. Hell, it's not even guaranteed to compile!
The problem does not appear to be with DoEvents, but with the code that you're trying to pause. Since we know nothing about that code and when the "pause" button does, it's impossible to say waht's going on.
|
|
|
|
|
The Pause button click event is not even firing to set the flag, except when the program is currently in my Form1 class, where that button is located. That is what it SEEMS like, anyway. My take on it is that when I try the Pause button while execution is inside the treeview usercontrol, (where execution seems to be spending the majority of its time under certain conditions) the button's click event can't fire because the program is not currently in Form1 to process it.
When I notice this the most, is when the treeview is cycling through a bunch of files in some folder, one after the other. If a file does not meet a certain set of criteria, it immediately moves to the next file in the folder, and this occurs rapidly. Since the treeview must update for every change in node selection for every file, the code is spending a lot of time in the usercontrol just spitting out updates to the treeview. I think that is when my Pause button Click event fails to fire. And I mean explicitly that...I can put a breakpoint in the button's Click event, and it never triggers.
When a scan of the treeview completes, the Pause button responds immediately.
|
|
|
|
|
treddie wrote: When I notice this the most, is when the treeview is cycling through a bunch of
files in some folder, one after the other. If a file does not meet a certain set
of criteria, it immediately moves to the next file in the folder, and this
occurs rapidly.
So does this code have a DoEvents in it that gets called kind of frequently??
|
|
|
|
|
I tried DoEvents every which way I could...In every loop and inside the usercontrol. My impression is that the ones in the usercontrol never work at all. The ones in the main form work when they can get a breather...That is, when execution is not currently inside the usercontrol code.
|
|
|
|
|
To make sure, I ran my own tests on DoEvents in a UserControl and it does work. The problem has to be somewhere else as far as I can tell. Again, we can't see your code, so it's impossible to tell you what's going on.
|
|
|
|
|
Dang. I was afraid of that. I think i buggered it up!
I'm going to have to go through it with a fine tooth comb, and figure out what I did, then. Which may just be an exercise in understanding something I will never use again. As I research threading more, there might be a reasonably easy way of making the transition to it.
|
|
|
|
|
Can anyone please compress the following code? This code is used to make the text property of radiobuttons in a groupbox display values from columns of a dataset.
For Each rad As RadioButton In GroupBox1.Controls
If b > 1 Then
rad.Text = ds.Tables("AddressBook").Rows(a).Item(b)
b = b - 1
End If
Next
a = a + 1
For Each rad As RadioButton In GroupBox2.Controls
If c > 1 Then
rad.Text = ds.Tables("AddressBook").Rows(a).Item(c)
c = c - 1
End If
Next
a = a + 1
For Each rad As RadioButton In GroupBox2.Controls
If d > 1 Then
rad.Text = ds.Tables("AddressBook").Rows(a).Item(d)
d = d - 1
End If
Next
|
|
|
|
|
i can loop through the rows in a dataset using the code below. But how can i loop through the individual items of the same row.
For Each myControl As Control In Me.Controls
If TypeOf myControl Is GroupBox Then
For Each rad As RadioButton In myControl.Controls
rad.Text = ds.Tables("AddressBook").Rows(b).Item(c)
Next
b = b + 1
End If
Next
|
|
|
|
|
Hi,
I'm not able to get the cell value for the selected row in the gridview, the code in the aspx page:
<asp:GridView runat="server" ID="gvElMaster" PageSize="5" Width="100%" ItemType="EMS.Ems_ElMaster"
DataKeyNames="ElMasterID" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
SelectMethod="GetElMaster" HeaderStyle-VerticalAlign="Middle"
HeaderStyle-HorizontalAlign="Center" CaptionAlign="Top" CellPadding="4" GridLines="None" ForeColor="#333333"
OnSelectedIndexChanged="gvElMaster_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:DynamicField DataField="ElName" />
<asp:DynamicField DataField="ElStartRegDate" />
<asp:DynamicField DataField="ElEndRegDate" />
<asp:DynamicField DataField="ElDate" />
<asp:CommandField ShowSelectButton="True" SelectText="Select" CausesValidation="False" InsertVisible="False" ShowCancelButton="False"></asp:CommandField>
</Columns>
</asp:GridView>
code behind:
Public Function GetElMaster() As IQueryable(Of Ems_ElMasterClass)
Return _db.DbSet_ElMasters
End Function
Protected Sub gvElMaster_SelectedIndexChanged(sender As Object, e As EventArgs) Handles gvElMaster.SelectedIndexChanged
MsgBox(gvElMaster.SelectedIndex)
MsgBox(gvElMaster.SelectedValue.ToString)
MsgBox(gvElMaster.SelectedRow.Cells(1).Text)
MsgBox(gvElMaster.SelectedRow.Cells(2).Text)
MsgBox(gvElMaster.SelectedRow.Cells(3).Text)
End Sub
I get empty text from all the cells
Development envirunment is:
- VS 2012
- Asp.net 4.5
- CodeFirst aproach
Thanks for the help
|
|
|
|
|
Hello Friend I am making a GUI for my vpn in visual basic and I am getting a problem when I am using
("perl something.pl" + somehting + something1 + something2)
but when I am using
("perl something.pl something1value something2value")
everything is working fine any solution please
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim IP As String = "xxx.xxx.xxx.xxx"
Dim Username As String = "root"
Dim Password As String = "mypassword"
Dim cmd As Renci.SshNet.SshCommand
Dim connInfo As New Renci.SshNet.PasswordConnectionInfo(IP, Username, Password)
Dim sshClient As New Renci.SshNet.SshClient(connInfo)
Dim something As String = TextBox1.Text
Dim something1 As String = TextBox2.Text
Dim something2 As String = TextBox3.Text
sshClient.Connect()
cmd = sshClient.RunCommand("perl something.pl" +something + something1 + something2)
Label1.Text = cmd.Result
End Sub
End Class
|
|
|
|
|