|
Here's the problem with using the Designer to do your database code. It's increased the level of difficulty in supporting problems like this about 10 fold. This is because the designer just wrote a bunch of code for you that you can't find and don't know anything about, let alone why the code works, or in most cases, DOESN'T work!
There's quite a number of possibilities that may cause this error. See this[^] for a good list of them.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Alright, thanks Dave I will take a look at that page and hopefully it will help me find my problem. Have a great day!
|
|
|
|
|
Ok, I got it. I had to put this in my code after my update line...
OleDbDataAdapter.Fill(mydataset.tablename)
pretty much just needed to refill the dataset. I am doing it for each table that I am updating.
I hope this helps someone else one day.
|
|
|
|
|
I wonder if anyone could help me solve this.
I am using VB.Net 2003 with Crystal Reports 10.
Example.
I have a VB form that has values in the text boxes. At the moment I am able to transfer these values to a Crystal Report via code like below
paramField = New ParameterField
discreteVal = New ParameterDiscreteValue
paramField.ParameterFieldName = txtSomething.text
' Set the first discrete value and pass it to the parameter
discreteVal.Value = param_value
paramField.CurrentValues.Add(discreteVal)
ParamFields.Add(paramField)
etc etc
The question is how you can capture values that are held in the datagrid e.g.
Name Dept Age
Alan Accounts 21
Sue Sales 27
Jim Accounts 35
Linda IT 30
Would it be something similar or is there a specific way of capturing values.
|
|
|
|
|
Are you looking at looping through every row of the datagrid? or get the value when a row/cell is selected?
|
|
|
|
|
I would be looping through the datagrid as the values are already there. I thought about putting values in an array and populating it that way. How would I then be able to populate the Crystal Report? Or is there a better way of doing this?
On the Crystal Report I put the values into a parameter field.
|
|
|
|
|
You can probably have a look at this[^]. The last solution shows you how to loop thru each record. The code is in c# I am sure you can just convert it to vb.net
|
|
|
|
|
i need to make pop3 server that can access and download email from http request. this program masu work with email client outlook express.
maybe its like Ypops ! but its not use pop3 its use http request. any pop3 request from outlook will be translate as http request.
Its like download our email via web.
anyone can help ... plisss i want to make it using visual basic 6
|
|
|
|
|
dmid wrote: plisss i want to make it using visual basic 6
That's probably going to kill off any volunteers. VB6 is quite old and isn't supported by Microsoft anymore. I haven't used it in about 6 years, since .NET came out.
The biggest problem you're going to have is that you need to write a HTTP client into your server that can parse and handle the web page your getting the mail from. The issue is when that web page changes, it'll pretty much destroy all the work you put into parsing the existing page.
You'll also have to handle paging on that page, where the number of emails exceed a certain number. You'll have to handle removing messages from the server and downloading images in the emails and downloading attachments.
And that doesn't even touch the POP3 side of your server.
The bottom line is this is NOT going to be any easy project. It'll probably take you about as long to write it as it'll take for your web-based email service to change the page layout on you! Or, even move the thing to a Java-based application, forcing you to completely scrap what you're doing anyway.
Today, most email providers have both SMTP/POP3 and a web-based client. So why all the work for something that's more-than-likely a redundent application?
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hello all,
Is there any way to catch the key pressed in VB.net 2005?
I want to create a simple form that will pop up a message when it detects any key pressed when it starts.
Thank you
|
|
|
|
|
Any key that is pressed in your application, or any key that is press system-wide? If it's system wide, then you're talking about a global keyboard hook. Just search the articles for "keyboard hook" and you'll find a bunch of examples.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hmm... ok I will try that.
However, I was just wondering why is the override onKeyPress doesn't work in visual basic.net 2005?
I was using the same function in 2003.
|
|
|
|
|
It does work. You have to set your form's KeyPreview property to true in order for the form key events to work. But, they will only work if your application has the input focus. They won't work for a global keyboard hook.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
HAHAHA... Thanks Dave.
|
|
|
|
|
I want to call functions of a C++ dll but Im having problems. The function in C++ in declared the next way:
__declspec( dllexport )int Initialize(char * in_szStatusLoc);
My code in Basic is:
Private Declare Function Initialize Lib "C:\Archivos de Programa\CallRex\CallrexApi.dll" (ByVal inszStatusLoc As String) As Integer
Private Sub Form_Load()
Dim error As Integer
error = Initialize("192.168.100.130")
End Sub
I alway get an error that says: Run-time error 49, Bad DLL calling convention.
What can be wrong?
|
|
|
|
|
Try changing the Declare to:
Private Declare Function Initialize Lib "callrexApi.dll" (ByRef inszStatusLoc As String) As Long
The full path to the .DLL was removed to allow for having the .DLL file in the same folder as the application .EXE without knowing what that path is ahead of time.
The Integer at the end was changed to a Long because your C++ header shows that it's returning an int , which is a 32-bit signed integer. In VB6, the equivilent datatype is a Long, not an Integer. Integer in VB6, IIRC, is a 16-bit signed integer.
My VB6 is really rusty; I haven't used it in about 6 years.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thank you for your answer. I just try it and I got exactly the same result. What else can be wrong?
|
|
|
|
|
Try changing the ByRef in your Declare back to ByVal.
I didn't notice this before, but I think the calling convention in the C++ header is wrong for use with VB6:
__declspec( dllexport )int Initialize(char * in_szStatusLoc);
I seem to remember something about VB6 expecting the _stdcall convention, not __declspec . If you have control over the source code for this .DLL, you'll have to change the call to _stdcall . If you can't change that .DLL, you'll have to write a wrapper around it in C++, that exposes _stdcall decorated functions and calls the __declspec version of the .DLL for VB.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi,
How to draw ellipse in PictureBox and save ellipse image from the picturebox to jpg or bmp. in VB6.0
Thanks & Regards
Kumaran
|
|
|
|
|
|
found out the problem with the code...i think.
when i click to add it to the database the msgbox comes up and basically says it cant find the path to the database... i don't know why, the database file is in the debug in the same project.
message:- 'could not find file 'U:\visual studio 2005\projects\manager login\manager login\bin\debug\PCBank'
Imports System.Data.OleDb
Public Class cust
Public conn As OleDbConnection
Public comm As OleDbCommand
Public dr As OleDbDataReader
Public da As OleDbDataAdapter
Dim icount As Integer
Dim str As String
Private Sub cust_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection 'establishes that conn is a new connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\PCBank.mdb" 'the name of the connection (name of the database on the end)
conn.Open() 'opens the connection
comm = New OleDbCommand 'establishes that comm is a new command
comm.Connection = conn 'the connection for the command is the connection specified
comm.CommandType = CommandType.Text 'the commands are in text
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=PCBank")
conn.Open()
comm = New OleDbCommand("insert into customers(CustomerID,CustomerSurname,CustomerForename) values('" & (tbID.Text) & "','" & (tbSur.Text) & "','" & (tbFor.Text) & "')", conn)
icount = comm.ExecuteNonQuery()
MsgBox("record inserted")
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
End Class
|
|
|
|
|
don't worry about it. finally managed to figure it out.
it was something so simple its stupid.
CustomerForename should of been CustomerForenames
PCBank needed .mdb at the end.
i feel like i've been wasting my entire life(or a couple of weeks)
thanks for all your help.
i'll probably be bugging you again soon
|
|
|
|
|
peteyshrew wrote: it was something so simple its stupid.
That happens alot in this business, even to the Pro's! :->
I noticed you're using the same connection string and just retyping it over and over when you need it, at least twice anyway. You might want to consider moving your database code to a seperate layer, or at least moving the connection code to a Shared (static in C#) method, like this:
Public Class SqlHelpers
Public Shared GetConnection(ByVal OleDbFileName As String) As OleDbConnection
' Your connection string goes here. Whether it's hard coded (bad idea!), or
' stored in the registry or in an app.config file, this method should
' retrieve it and create a new connection object out of it.
'
' This example will see if the specified database exists in the same path
' the .EXE was launched from, and if so, create a new OleDbConnection out of it.
Dim FullPath As String = Path.Combine(Application.StartupPath, OleDbFileName)
If File.Exists(FullPath) Then
Dim connString As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", FullPath)
Return New OleDbConnection(connString)
Else
Throw New FileNotFoundException("Unable to find the database file " & _
OleDbFileName & " in the application startup path!")
End If
End Sub
.
. other helper methods...
.
End Class
When you want to get a new connection to the database, just do this:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
Dim conn As OleDbConnection = SqlHelpers.GetConnection("PCBank.mdb")
Dim comm As New OleDbCommand("insert into customers CustomerID, CustomerSurname, CustomerForename) " & _
"values('" & (tbID.Text) & "','" & (tbSur.Text) & "','" & (tbFor.Text) & "')", conn)
icount = comm.ExecuteNonQuery()
MsgBox("record inserted")
Catch ex As Exception
MsgBox(ex.Message)
Finally
If Not IsNothing(conn) AndAlso conn.State <> ConnectionState.Closed Then
conn.Close()
End If
End Try
End Sub
This is nowhere near the "perfect" implementation, but it gives you an idea of what should be going on.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
The way I work with connection strings is I store them in the app.config file then I have a function to retrieve it like this:
Public Shared Function GetConnectionString(ByVal strConnection As String) As String
Dim strReturn As New String("")
If Not String.IsNullOrEmpty(strConnection) Then
strReturn = ConfigurationManager.ConnectionStrings(strConnection).ConnectionString
Else
strReturn = ConfigurationManager.ConnectionStrings("YourConnectionStringName").ConnectionString
End If
Return strReturn
End Function
I do it this way that way I can have multiple connection strings and just pass the name of the connection string, otherwise it defaults to the default connection.
SELECT * FROM Users WHERE Clue > 0
ERROR: 0 Rows Returned
|
|
|
|
|
dude try to put your database in the folder "BIN" of your project. i encounter that problem too and i fix it when i put my database in the folder "BIN" of my project. if the error still prompt, post it again.
Don't block the drive way of all the newbies in programming. )
|
|
|
|