|
Hello,
I need help with this. Everytime I run my code I get this error message "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" at ExecuteNonQuery.
If someone is an SQL and VB.Net guru any help would be appreciated.
Thanks.
cmd.Parameters.Add(param22)<br />
<br />
cmd.CommandText = "EXECUTE AddtnlComments"<br />
con.Open()<br />
cmd.ExecuteNonQuery()<br />
con.Close()
|
|
|
|
|
Show more of the error message. The part you have shown is only telling that an error occured during a database call.
---
b { font-weight: normal; }
|
|
|
|
|
In my code below,
When I go to a new line, it will not let me put the ( ) at the end of Dim ds As New DataSet
I can enter the parenthesis () but it removes them when I go to a new line
Also the dataAdapter.Fill(ds, "progs")
gives me the error
"Declaration expected"
Here is mycode so far:
**************************
**************************
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim connectionString As String = "workstation id=Dude;packet size=4096;integrated security=SSPI;data source=Dozer;" & _
"persist security info=False;initial catalog=programmersheaven"
Dim conn As New SqlConnection(connectionString)
Dim commandString As String = "SELECT " + _
"artId, title, topic, " + _
"article.authorId as authorId, " + _
"name, lines, dateOfPublishing " + _
"FROM " + _
"article, author " + _
"WHERE " + _
"author.authorId = article.authorId"
Dim dataAdapter As New SqlDataAdapter(commandString, conn)
Dim ds As New DataSet
dataAdapter.Fill(ds, "progs")
|
|
|
|
|
You don't need the paranthesis when there is no parameters, oddly enough.
You can't put code outside a method, only declarations.
---
b { font-weight: normal; }
|
|
|
|
|
I moved my code under sub page_load but it still need not work?
Sorry, I am so very new at this
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim connectionString As String = "workstation id=DOZER;packet size=4096;integrated security=SSPI;data source=Dozer;" & _
"persist security info=False;initial catalog=programmersheaven"
Dim conn As New SqlConnection(connectionString)
Dim commandString As String = "SELECT " + _
"artId, title, topic, " + _
"article.authorId as authorId, " + _
"name, lines, dateOfPublishing " + _
"FROM " + _
"article, author " + _
"WHERE " + _
"author.authorId = article.authorId"
Dim dataAdapter As New SqlDataAdapter(commandString, conn)
Dim ds As New DataSet
dataAdapter.Fill(ds, "prog")
Dim dataTable As DataTable = ds.Tables("prog")
End Sub
|
|
|
|
|
Standard question #1:
What do you mean by "not working"?
Standard question #2:
What error message do you get?
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for replying,
First I have been taking a tutorial from
|
|
|
|
|
The error message "Declaration Expected" means exactly what is says. You have code where only declarations are allowed. I already explained this. As it's a compiler error message, it has nothing what so ever to do with the database. The database doesn't even have to exist for the code to compile.
Of course you are getting a blank page. What else could you get? You load some data from the database, then you don't do anything with it. What could possibly show up on the page?
---
b { font-weight: normal; }
|
|
|
|
|
Thanks again, I am getting closer for a lowly Newbie. I appreciate your getting me closer.
Now I must figure what I am doing wrong to get it to display on the browser. Probably something extremely simple but I don't know what that is.
Thanks for getting me this far. At least I no longer have the "Declaration expected" problem.
I was hoping that the following code would display to the browser:
Dim ds As New DataSet
dataAdapter.Fill(ds, "arthor,article")
Dim dataTable As DataTable = ds.Tables("arthur,article")
|
|
|
|
|
You have to put something on the page for it to show up in the browser. You can for an example put a DataGrid on the page, and use the DataTable as DataSource for the grid.
---
b { font-weight: normal; }
|
|
|
|
|
hi, i'm just a vb.net beginner, and i'm developing a resources monitor which runs as a windows service...
before installing it (using the installutil command in the VS command prompt) i test it as a windows application, and everything works fine...there's a button that, when clicked, performs the things i want to...but when i create the service, i paste the code into a timer.elapsed event, but nothing happens...
the timer is enabled in the onstart method of the service, and then disabled in the onstop method...
also, the service install succesfully on the machine...
below is the code i'm trying to run...
Private Sub Timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer.Elapsed
Dim dirs() As String
Dim directorio As String
Dim arch As String
Dim archs() As String
Dim objarch As FileInfo
Dim tamaño As Long
Dim from As String
Dim para As String
Dim mailbody As String
Dim asunto As String
dirs = Directory.GetDirectories("d:\", "ssa*")
For Each directorio In dirs
archs = Directory.GetFiles(directorio, "*.pst")
For Each arch In archs
objarch = New FileInfo(arch)
If objarch.Length > 1073741824 Then
tamaño = objarch.Length / (1024 * 1024) 'MBytes
mailbody = "El usuario debe limpiar sus Personal Folders!!"
asunto = "Archivo .pst grande"
MsgBox("Enviando mail!!")
enviarmail(from, para, mailbody, asunto) 'method for sending mails
End If
Next
Next
End Sub
p/d: also, if i write any other code instead if this one, it works great...just don't know why is this happening!
|
|
|
|
|
Hi, not that I've ran your code or anything, but I am guessing at least one of your problems is with MsgBox("Enviando mail!!") . I am trying myself to get interface working from service, but noone answered my other post.
There is a property System.ServiceProcess.ServiceType.InteractiveProcess that it says will allow service to interact with desktop (ie have user interface), but, I have no idea how to use this either.
Anyone know ?
|
|
|
|
|
mmm, could be...but, let me know if i understood well..you are saying that the entire code doesn't works because of that? or just that the message box will not work but the rest should?
i think that the msgbox is blocking the rest of the code, now i'll try again and tell you how it goes!
thanks for the support!!!
|
|
|
|
|
Hi,
I still dont have solution, but I found how to use that attribute ServiceType.InteractiveProcess , you have to write it to the registry yourself, I do it in the following installer method:
Private Sub LogWriterInstaller_AfterInstall(ByVal sender As System.Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles LogWriterInstaller.AfterInstall
This is the code I add:
Dim regK As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\Service1", True)<br />
If regK Is Nothing Then<br />
Else<br />
regK.SetValue("Type", System.ServiceProcess.ServiceType.InteractiveProcess)<br />
End If<br />
My code does allow me to use System.Windows.Forms.MessageBox.Show however, I cant simply create an instance of my visual form and hit show()
Keep working away, I'm almost outa time and have to find another way to complete my project (Simply showing a dialog on window shutdown and entering some info.)
Brian
|
|
|
|
|
that's a good one, but i've just tried the code without the msgbox, and instead of it i put a Beep() so that i know that the code was running, but i'm still stucked...
again, thanks for your support, and keep going with your work! if i know how to do what you're doing i'll post it!
|
|
|
|
|
Hi, simple way for me to find which lines it didnt make it to was:
<br />
Dim writer As System.IO.StreamWriter = New System.IO.StreamWriter("c:\TestDataLog.txt", True) 'Apend<br />
line of code1<br />
writer.WriteLine("point 1")<br />
line of code2<br />
writer.WriteLine("point 2")<br />
etc etc<br />
writer.Close()<br />
Hope that helps find the line it stops at. (if u dont already know)
|
|
|
|
|
Because I couldnt use interface from a service (apart from msgbox.show("Blah")) I wrote my program as an application, which also runs on startup (via simple enough registry mod in installer code), was hidden from view and ALT+TAB order, and becomes visible when it needs to be used.
How did the service way go ?
|
|
|
|
|
that's a good idea...but i need to implement this solution as a service because of requirements here at my workk...
well, remember that problem i was having with the service not working fine? well, the problem was that the user i was using to install the service didn't had some permissions over a directory which i was tryng to monitor (via the service)...so, i changed the user and now it works fine! now, to find the problem, what i did was to code the part which i thought that was causing problems witch 'try/catch' statements...and catch the exception and send it as a mail to my acount...so there i realized that was a permission problem, since the message was something like "couldn't access path d:\. Not enough permissions"
and now i'm implementing the service's control panel....how are you doing with your work???
|
|
|
|
|
well, sounds like your good at this! All my project had to do was wait until shutdown, then display a form to the user, accept some input, then they click submit or cancel shutdown, and it either shutdowns or hides the program again for later. Could have been done in a couple hours by a pro, just I wasted time trying service with interface, also wasted time using listview with checkboxes (because i wanted some colour text) but had problems disable checking on click which was easier with checkedlistbox.
Hopefully I can be of some use for your next post.
Brian
|
|
|
|
|
|
Don't spam the forum.
Also, if you make an effort to write proper english, you have a better chance of getting an answer. Many people here doesn't have english as their first language, or even second.
"do u c wat i m getn at?"
---
b { font-weight: normal; }
|
|
|
|
|
If someone could/would help you would have received an answer by now. Re-posting your question to the board (spamming) is not considered considerate behaviour.
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
Consider this table format(Id, KK, Value, Period). I have got a datatable named abc in a dataset loaded with this huge data spanning over 24 months(yyyymm period format). I want to search for a particular field (KK) from this datatable and get the data for KK in descending order of period. Note that the value is 0 for certain period. i.e.I want to obtain the value (value <> 0) for the most recent period for KK from the datatable.
Any help will be useful.
With Best Regards,
Mayur
-- modified at 7:24 Monday 16th January, 2006
|
|
|
|
|
You could use the DataView functionality.
You can get one via myTable.CurrentView (you could also create a new one). The view has a property sort which you can set to "Period DESC" and a property Rowfilter which you could set to "Value <> 0" (probably its "!= 0 - im not sure). Now you can iterate over the DataView
foreach (DataRowView drv in myDataView){
drv.Row;
object kkVal = drv["KK"];
}
or just take the first element
object firstVal = myDataView[0]["KK"];
|
|
|
|
|
Robert, thnx for your help. Since I am a fresher in .Net, could you plz explain how data can be filled in the dataview and then searched.
With Best Regards,
Mayur
|
|
|
|
|