|
Honestly, it's hard for me to tell, but the error seems to me to be occuring because the arguments you are passing to your function are not appropriately defined.
|
|
|
|
|
But why would it work under my profile?
|
|
|
|
|
Without seeing the code in your count method in Form1, it's impossible to tell you where the problem is. What we can tell you is that you tried to set a property or call a method on an object that is Nothing , or null in C#.
You probably retrieved an object, or a collection of objects, from somewhere and tried to use it without checking to see if an object was actually returned.
|
|
|
|
|
Well, here is my code for the count function:
Public Function count(ByVal search As String, ByVal startDate As String, ByVal endDate As String) As Integer<br />
Dim number As Integer<br />
Dim pubs As New SqlConnection(ConfigurationManager.ConnectionStrings("WIA_Report_Builder.My.MySettings.wiaConnectionString").ConnectionString)<br />
'pubs = ConfigurationManager.ConnectionStrings("wiaconnectionstring")<br />
'pubs.ConnectionString = ConfigurationManager.ConnectionStrings("WIA_Report_Builder.My.MySettings.wiaConnectionString").ConnectionString<br />
Dim connection As DbConnection = New SqlConnection()<br />
connection.ConnectionString = pubs.ConnectionString<br />
Dim cmd As DbCommand = connection.CreateCommand()<br />
cmd.CommandType = CommandType.Text<br />
Select Case search<br />
Case "TotalAdultPart"<br />
cmd.CommandText = "Select Count (*) from Demographics where AgeatEnroll >= 22"<br />
Try<br />
connection.Open()<br />
number = cmd.ExecuteScalar<br />
<br />
Catch ex As Exception<br />
Finally<br />
connection.Close()<br />
End Try<br />
....<br />
<br />
End Select<br />
Return number<br />
<br />
end function<br />
|
|
|
|
|
Stepping through the code line by line will tell you where the error is. All you have to do is set a breakpoint on the first line in the method code, then run your app. The debugger will stop the code when it hits the breakpoint. Then all you have to do is single-step until you reach the error.
Aptiva Dave wrote: Dim pubs As New SqlConnection(ConfigurationManager.ConnectionStrings("WIA_Report_Builder.My.MySettings.wiaConnectionString").ConnectionString)
The most obious failure here that can cause the error you're seeing is that ConfigurationManager.ConnectionStrings("WIA_Report_Builder.My.MySettings.wiaConnectionString") may have returned Nothing, on which you're trying to retrieve the value of the ConnectionString property.
From the looks of things, you're having problems retrieving the connection string from a configuration file, correct??
Also, you've (tried to) created a couple of SqlConnection objects. You only need one.
|
|
|
|
|
The problem I have using a break point and debugging that way is that I can get the program to run on my profile of my machine by just running the exe outside of vs 2005.
I don't believe that the issue is from getting to the connection string, but where do you see the multiple SqlConnection objects?
|
|
|
|
|
One possibility is to have your .exe program write a line to a text file after every couple of lines of code in the area where you think the problem is. Then you can see what the last line written was -- you know the error is after that, but before the next line write.
Also perhaps try simply writing the values of the variables in question to a file during the run and see what gets written.
These techniques have helped me in the past.
|
|
|
|
|
That sounds like a good idea. Don't know why I didn't think to do that. Guess I frustrated a bit with it not working and with all of my other help desk calls today.
Anyways, I'll try that when I get back to work tomorrow. Thanks
|
|
|
|
|
Then create another user on your machine and try it.
Better yet, get VMWare or Microsoft's Virtual PC's, install an O/S on it, then your app, and try it again.
|
|
|
|
|
I want to be able to modify a control on my mainform (Form1) from a backgroundworker on Form2. If I first open Form2 I can make it happen by calling the BGW from the button on Form2. However, I cannot call the BGW on Form2 directly from Form1. I don't see why not.
Thanks!
Public Class Form2
Private Delegate Sub SetTextBoxTextDelegate(ByVal text As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.BackgroundWorker1.RunWorkerAsync()
End Sub '
Private Sub SetTextBoxText(ByVal text As String)
Form1.TextBox1.Text = text
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Me.Invoke(New SetTextBoxTextDelegate(AddressOf SetTextBoxText), "Set this text")
End Sub
End Class
|
|
|
|
|
No one can help me??
|
|
|
|
|
Patience.
You shouldn't be updating Form1 controls from Form2 at all. Form2 would be unable to exist without an instance of Form1 if you did. This violates encapsulation and OOP principles.
Form2 should be exposing events that Form1 can subscribe to, where then, Form1 can update it's own controls without Form2 knowing anything about it.
|
|
|
|
|
OK, that helps.
BGW.reportprogress is what I need I think.
Thanks
|
|
|
|
|
Hi All,
I want to broadcasting some audio over LAN, But I don't know how to do it.
Let me explain it clearly, suppose I have a server and some clients connected to it. Now I want if I play some audio file on my server then that audio file must be played on the clients too.
Can anyone please help me?
Regards,
Paramhans
|
|
|
|
|
Check into Microsoft's Media Encoder 9.0 SDK. It'll let you setup and broadcast audio and video. The client's will, of course, have to be running Media Player and connect to the URL exposed by your audio server to connect to.
|
|
|
|
|
Hello,
I have a vb.net application that runs on a server. There are five client PC's that are connected to the server and all the data is saved on the server from my vb.net application.
To add a record, two sql runs under Commit transaction. One runs an insert statement while the other updates a record.
However, I have noticed a error. The update statement has lot of other fields which are stored correctly, but sometimes (say one out of 100 record) it doesnt stores the correct value to a numeric field. This field is integer and the data is stored from a text box.
This is creating a lot of trouble in my application. Please help.
|
|
|
|
|
That description isn't specific enough to solve your problem. You are going to have to do some digging around in your application before we can help you.
Have you stepped through the code? Have you checked the values going to the database? Have you parsed the text box correctly? Can you recreate the scenario in which the value is wrong? If not, what investigations have you done to determine what the scenarios the number is wrong?
|
|
|
|
|
Hill all
I thought it would be the right place to post this Question in this Forum. Because its a lot Problems on VB than SQL. i have a Problem with one of my Parameters. i have the Following Procedure.
<br />
USE [ValRollClients]<br />
GO<br />
<br />
SET ANSI_NULLS ON<br />
GO<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
ALTER Proc [dbo].[Save_Client] <br />
(<br />
--Carry Original values before Update<br />
@Original_Client_ID int,<br />
@Original_Client_Name varchar(50),<br />
@Original_Contact_Person varchar(20),<br />
@Original_Purchase_date datetime,<br />
@Original_Client_Address varchar(50),<br />
@Original_Client_Telephone varchar(20),<br />
@Original_Client_Cell_No varchar(20),<br />
@Original_SerialNumber varchar(20),<br />
@Original_Product_Status int,<br />
@Original_Client_Email varchar(30),<br />
--Carry values after the update has been done<br />
<br />
@Client_Name varchar(50),<br />
@Contact_Person varchar(20),<br />
@Purchase_date datetime,<br />
@Client_Address varchar(50),<br />
@Client_Telephone varchar(20),<br />
@Client_Cell_No varchar(20),<br />
@SerialNumber varchar(20),<br />
@Product_Status int,<br />
@Client_Email varchar(30)<br />
)<br />
as<br />
Update Clients set<br />
Client_Name = @Client_Name,<br />
Contact_Person = @Contact_Person,<br />
Purchase_date = @Purchase_date,<br />
Client_Address = @Client_Address,<br />
Client_Telephone = @Client_Telephone,<br />
Client_Cell_No = @Client_Cell_No,<br />
SerialNumber = @SerialNumber,<br />
Product_Status = @Product_Status,<br />
Client_Email = @Client_Email<br />
Where<br />
(Client_ID = @Original_Client_ID)<br />
And<br />
(Client_Name = @Original_Client_Name or <br />
@Original_Client_Name IS NUll AND Client_Name Is Null)<br />
And <br />
(Contact_Person = @Original_Contact_Person or <br />
@Original_Contact_Person Is Null And Contact_Person IS Null)<br />
And<br />
(Purchase_Date = @Original_Purchase_date or <br />
@Original_Purchase_date is Null And Purchase_date Is Null)<br />
And <br />
(Client_Address = @Original_Client_Address OR <br />
@Original_Client_Address IS Null And Client_Address is Null)<br />
And<br />
(Client_Telephone = @Original_Client_Telephone OR <br />
@Original_Client_Telephone Is Null And Client_Telephone Is Null)<br />
And <br />
(Client_Cell_No = @Original_Client_Cell_No OR <br />
@Original_Client_Cell_No Is Null And Client_Cell_No IS Null) <br />
And<br />
(SerialNumber = @Original_SerialNumber Or <br />
@Original_SerialNumber is NUll And SerialNumber Is Null)<br />
And<br />
(Product_Status = @Original_Product_Status Or<br />
@Original_Product_Status Is NUll And Product_Status Is Null)<br />
ANd<br />
(Client_Email = @Original_Client_Email Or <br />
@Original_Client_Email is Null And Client_Email Is Null)<br />
<br />
--refreshing the data <br />
;select Client_ID,Client_Name,Contact_Person,Purchase_date,<br />
Client_Address,Client_Telephone,Client_Cell_No,SerialNumber,<br />
Product_Status,<br />
Client_Email <br />
from Clients<br />
Where (Client_ID = @Original_Client_ID)<br />
<br />
<br />
And am Calling the Procedure in vb.net like this
<br />
cmdupdate.CommandText = "Save_Client"<br />
<br />
cmdupdate.CommandTimeout = 0<br />
<br />
cmdupdate.CommandType = CommandType.StoredProcedure<br />
<br />
cmdupdate.Connection = con<br />
<br />
cmdupdate.Parameters.Add("@Client_Name", SqlDbType.VarChar, 50, "Client_Name")<br />
<br />
cmdupdate.Parameters.Add("@Contact_Person", SqlDbType.VarChar, 20, "Contact_Person")<br />
<br />
cmdupdate.Parameters.Add("@Purchase_date", SqlDbType.DateTime, 8, "Purchase_Date")<br />
<br />
cmdupdate.Parameters.Add("@Client_Address", SqlDbType.VarChar, 50, "Client_Address")<br />
<br />
cmdupdate.Parameters.Add("@Client_Telephone", SqlDbType.VarChar, 20, "Client_Telephone")<br />
<br />
cmdupdate.Parameters.Add("@Client_Cell_No", SqlDbType.VarChar, 20, "Client_Cell_No")<br />
<br />
cmdupdate.Parameters.Add("@SerialNumber", SqlDbType.VarChar, 20, "SerialNumber")<br />
<br />
cmdupdate.Parameters.Add("@Product_Status", SqlDbType.VarChar, 4, "Product_Status")<br />
<br />
cmdupdate.Parameters.Add("@Client_Email", SqlDbType.VarChar, 30, "Client_Email")<br />
<br />
<br />
da = New SqlDataAdapter<br />
<br />
da.UpdateCommand = cmdupdate<br />
<br />
Dim prmClient_ID As SqlParameter = cmdupdate.Parameters.Add("@Original_Client_ID", _<br />
SqlDbType.Int, 50, "Client_ID")<br />
<br />
prmClient_ID.SourceVersion = DataRowVersion.Original<br />
<br />
Dim prmClient_Name As SqlParameter = cmdupdate.Parameters.Add("@Original_Client_Name", _<br />
SqlDbType.VarChar, 50, "Client_Name")<br />
<br />
prmClient_Name.SourceVersion = DataRowVersion.Original<br />
<br />
Dim prmContact_Person As SqlParameter = cmdupdate.Parameters.Add("@Original_Contact_Person", _<br />
SqlDbType.VarChar, 50, "Contact_Person")<br />
<br />
prmContact_Person.SourceVersion = DataRowVersion.Original<br />
<br />
<br />
Dim prmPurchase_Date As SqlParameter = cmdupdate.Parameters.Add("@Original_Purchase_date", _<br />
SqlDbType.DateTime, 8, "Purchase_Date")<br />
<br />
<br />
prmPurchase_Date.SourceVersion = DataRowVersion.Original<br />
<br />
<br />
Dim prmClient_Address As SqlParameter = cmdupdate.Parameters.Add("@Original_Client_Address", _<br />
SqlDbType.VarChar, 50, "Client_Address")<br />
<br />
prmClient_Address.SourceVersion = DataRowVersion.Original<br />
<br />
<br />
Dim prmClient_telephone As SqlParameter = cmdupdate.Parameters.Add("@Original_Client_Telephone", _<br />
SqlDbType.VarChar, 20, "Client_Telephone")<br />
<br />
prmClient_telephone.SourceVersion = DataRowVersion.Original<br />
<br />
<br />
Dim prmClient_Cell_No As SqlParameter = cmdupdate.Parameters.Add("@Original_Client_Cell_No", _<br />
SqlDbType.VarChar, 20, "Client_Cell_No")<br />
<br />
prmClient_Cell_No.SourceVersion = DataRowVersion.Original<br />
<br />
<br />
Dim prmSerialNumber As SqlParameter = cmdupdate.Parameters.Add("@Original_SerialNumber", _<br />
SqlDbType.VarChar, 20, "SerialNumber")<br />
<br />
prmSerialNumber.SourceVersion = DataRowVersion.Original<br />
<br />
<br />
Dim prmProduct_Status As SqlParameter = cmdupdate.Parameters.Add("@Original_Product_Status", _<br />
SqlDbType.Int, 4, "Product_Status")<br />
<br />
prmProduct_Status.SourceVersion = DataRowVersion.Original<br />
<br />
Dim prmClient_Email As SqlParameter = cmdupdate.Parameters.Add("@Original_Client_Email", _<br />
SqlDbType.VarChar, 20, "Client_Email")<br />
<br />
prmClient_Email.SourceVersion = DataRowVersion.Original<br />
<br />
<br />
Try<br />
con.Open()<br />
<br />
<br />
da.Update(dsdata)<br />
<br />
con.Close()<br />
<br />
Catch ex As SqlClient.SqlException<br />
<br />
MsgBox(ex.Message)<br />
<br />
End Try<br />
<br />
<br />
<br />
i get an Error when i try to save "Concurency violation:The UodatedCommand Affected 0 records"
What is Wrong with my code
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
A concurrency error (0 rows affected) problem occurs because the data that is used to uniquely identify the record that's being updated no longer (or never did) match the data in the database. Since no record matched the WHERE clause, no update was performed.
Check your code for what you're passing into the SQL stored proc and check the stored proc to make sure it's doing exactly what it should be.
|
|
|
|
|
Good Afternoon Dave
The Problem was the Dimension of the Parameters that i created from the Dimension of the Parameters of the stored procedure and that were created out of gauss work from my mind, that does not match the field from the table. from this i learned that the size of the Field from the table, must apply even down when you create parameters in vb.net,they must remain constant.
Thanks DAVE
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hi all,
when i copy the contents of word file to rich text box , then formatting is not proper shown . Specially if word file contains table structure or Graphic.
anybody have idea that how can i preserve formatting of word file in richtextbox ?
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Didn't I answer this yesterday ? If a rch text box was as rich as Word, there would be no market for Word.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
How about if you save as RTF from Word then open it in a rich text box?
|
|
|
|
|
if save as RTF then works well. but i give facility to user to copy some part of word file and paste in richtextbox.
so problem is that check format of data to be copied in richtext box.
have any idea about this thing?
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Rupesh Kumar Swami wrote: when i copy the contents of word file to rich text box , then formatting is not proper shown .
Of course not. The RTB doesn't support everything Word does, including formatting options. You're not going to be able to "force" this to work using the RichTextBox.
|
|
|
|
|