|
I've this VB .NET Windows application that uses MS Access.
I am converting it to use SQL Server as backend.
What I've done so far (in the .vb and in the .resx) files: 1. modified the connection strings.
2. Changed the OleDbParameters to add "@" at the beginning of the parameter name like ...new OleDbParameters("@StartDate",....)
3. Added "@" at the beginning of the Adapter's command parameters like: UpdateEventTypeAdapter.UpdateCommand.Parameters("@EventTypeID").Value = .....
I basically work with web applications, so I don't exactly know/remember whether I should change anything else. For example - the DataSet xsd files. I haven't touched them at all. I am getting Object Reference not set to an instance...error from one of the DataSets.
Any idea what I am missing?
Thanks.
Ekjon
|
|
|
|
|
How do you get an exception from a dataset - it's null ? If so, check carefully the code that creates it and what it calls, etc. You are probably swallowing an exception higher up. You could also try moving to the SQL Server specific classes instead of the OleDB ones.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am writing a software program. When I tried to add a student and then check the student drop down box the student added successfuly, but when I try to add a lesson the lesson does not add. I added a message box to see if the info was adding to the dataRow for the database Update and the info showed up in the messageBox.
When I check the lesson listView the lesson is not there.
How do I find out if the lesson is adding to the database?
I am using SQL Server Express 2005 and the Copy to output directory is set to copy always.
Here is my code.
Public addRow As DataRow
MsgBox(txtInstrument.Text & "," & Convert.ToInt32(cboSelectStudent.SelectedValue) & "," & Convert.ToDateTime(dtpStartDate.Text) & "," & Convert.ToDateTime(dtpEndDate.Text) & "," & Convert.ToDateTime(lvwItem.SubItems(1).Text) & "," & intDay & "," & Convert.ToInt32(cboSelectTeacher.SelectedValue) & "," & intLessStat)
addRow = lpDataSet.tbl_lessons.Newtbl_lessonsRow()
addRow("less_instrument") = txtInstrument.Text
addRow("stud_id") = Convert.ToInt32(cboSelectStudent.SelectedValue)
If dtpStartDate.Visible = True Then
addRow("less_start_date") = Convert.ToDateTime(dtpStartDate.Text)
End If
If dtpEndDate.Visible = True Then
addRow("less_end_date") = Convert.ToDateTime(dtpEndDate.Text)
End If
If lvwChooseTimeslot.Visible = True Then
addRow("less_time") = Convert.ToDateTime(lvwItem.SubItems(1).Text)
addRow("less_day") = intDay
addRow("teach_id") = Convert.ToInt32(cboSelectTeacher.SelectedValue)
End If
addRow("less_status") = intLessStat
lpDataSet.tbl_lessons.Rows.Add(addRow)
lessonTableAdapter.Update(addRow)
|
|
|
|
|
You select from the database again and see if your record is there. I would write actual database code to do the update, then I wouldn't have any questions that it worked.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
>When I check the lesson listView the lesson is not there.
Is the listview control bound? If it's not then it won't automatically pick
up the changes in the db.
>How do I find out if the lesson is adding to the database?
One way is in VS, in your Data Sources window, right click the
table name and click "Preview Data".
|
|
|
|
|
I know how to control multiple click functions with a single button:
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click, button2.click but I have a different kind of problem. I have, say, three buttons: Button1, Button2 and Button3. Each has a textbox associated with it: TextBox1, TextBox2 and TextBox3. I have some code for each one that is exactly the same, save for the textbox it controls, simplified below:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "Test"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = "Test"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = "Test"
End Sub
Is there a way to make this into a single subroutine, or am I stuck creating a fourth subroutine, and passing all the values to it?
|
|
|
|
|
you can do this by checking the name or tag of the button that did the clicking ( it's passed in as sender, you just need to cast it to be a button ), then perform your action based on which button you find it was.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
elaborating on Christian's reply, you can figure out which button got pressed by
casting sender to a Button (say myButton); and when you have assigned each TextBox to
its corresponding Button's Tag (a Tag is a freely available reference), you can
simply cast myButton.Tag to myTextBox and operate on it.
|
|
|
|
|
Do you know how to make a control array?
I guess that would help you resolve your problem.
|
|
|
|
|
|
Sorry, I posted to the wrong forum...
I, try to move it to the C# forum...
|
|
|
|
|
Hiii Experts
I am Working on Outlook 2003 and my problem is i want to get the handle of word mail editor. in outlook our mail editor type is ms word and i want to get the handle of this document not the application. how can i get this.
Plz Help
Thanx
Mitesh Khatri
|
|
|
|
|
Hi,
I need to reduce the flickering on listview when change the backcolor of subitems of each and every item in listview continously(for eg : 5 times per second).
Thanks,
Latha
Latha.P
Raja Engg College,
Madurai.
|
|
|
|
|
Try listview1.suspendlayout before making the changes and listview1.resumelayout afterwards
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Sorry, I have already used that, but still flickering.
Latha.P
Raja Engg College,
Madurai.
|
|
|
|
|
Sorry, out of ideas then.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
|
I have "half an answer" here for you.
I went through google and found the reason for the flicker is that a listview repaints the whole control every update.
There is a solution in c# that overrode the control, and disabled the "erase background" message, so when the listview redrew itself, flicker would be significantly reduced. Unfortunately, I lost the web site with the code in, but I do have the vb.net version of the code, which is attached.
I hope it works for you! And sorry to the originial author that I cant properly reference this - I have tried searching google, but cant find it again.
Anyway, here is the code, along with a simulated "change background color" loop:
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
Dim lv As New FlickerFreeListView
lv.Left = 0
lv.Top = 0
lv.Width = 200
lv.Height = 200
Me.Panel1.Controls.Add(lv)
For x As Integer = 0 To 10
lv.Items.Add(New ListViewItem(New String() {"hello", "Hello", "HELLO", x.ToString}))
Next
For x As Integer = 0 To 100
lv.Items(0).BackColor = Color.Red
Application.DoEvents()
System.Threading.Thread.Sleep(100)
lv.Items(0).BackColor = Color.Blue
Application.DoEvents()
System.Threading.Thread.Sleep(100)
Next
End Sub
And the actual code that overloads the listview. Just add this to your project and you can replace a listview with a flickerfreelistview...
Public Class FlickerFreeListView
Inherits ListView
Sub New()
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.EnableNotifyMessage, True)
End Sub
Protected Overrides Sub OnNotifyMessage(ByVal m As System.Windows.Forms.Message)
If m.Msg <> &H14 Then
MyBase.OnNotifyMessage(m)
End If
End Sub
End Class
|
|
|
|
|
C# Code is:
class ListViewNF : System.Windows.Forms.ListView
{
public ListViewNF()
{
//Activate double buffering
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
//Enable the OnNotifyMessage event so we get a chance to filter out
// Windows messages before they get to the form's WndProc
this.SetStyle(ControlStyles.EnableNotifyMessage, true);
}
protected override void OnNotifyMessage(Message m)
{
//Filter out the WM_ERASEBKGND message
if(m.Msg != 0x14)
{
base.OnNotifyMessage(m);
}
}
}
found the code at: http://geekswithblogs.net/cpound/archive/2006/02/27/70834.aspx[^]
|
|
|
|
|
Yep - that looks like the code I savaged
It will have a more thorough description of what the code is doing too.
|
|
|
|
|
Heheh happy to help
Also for all the people new to VB.net and programming in general, if you have used the standard listview in your program and want to use the flicker free one discussed here, u dont need to go through every form and replace the listview with the flickerfree one using the code example. Simply go into the designer of the forms and change your ListView type to FlickerFreeListView
Example:
[Declaration]
Friend WithEvents ListView1 as System.Windows.Forms.ListView
[InitializeComponent]
Me.ListView1 = New System.Windows.Forms.ListView
Change to:
[Declaration]
Friend WithEvents ListView1 as FlickerFreeListView
[InitializeComponent]
Me.ListView1 = New FlickerFreeListView
do a replace all in your entire project for "as System.Windows.Forms.ListView" and "= New System.Windows.Forms.ListView" and presto, listview flicker solved in under a min.
HTH all the newbies not sure how to use the class
Regards,
Richard
|
|
|
|
|
Hi,
what is the difference between those and which is faster?
example:
a=2
b,c,d,e=1
1)if a=1 and b=1 and c=1 and d=1 and e=1 then....
2)if a=1 andAlso b=1 andAlso c=1 andAlso d=1 andAlso e=1 then....
3)if a=10 or b=10 or c=10 or d=10 or e=1 then....
4)if a=10 orElse b=10 orElse c=10 orElse d=10 orElse e=1 then....
Thanks in advance
|
|
|
|
|
Wow - VB sure sucks.
http://visualbasic.about.com/od/usingvbnet/l/bldykvbnetlogop.htm[^]
Looks like the answer is that the old operators do not optimise in any way.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
This is in no way different from the way C# works with &[^] and &&[^]...
|
|
|
|
|
The way I read it, it was saying that VB6 would evaluate the whole line even when it knew it was going to fail, so you can't do if (x != null && x.y != 0 ).
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|