Default Date Problem With VB Object And SQL Server Database
I am working on VB 6 and SQL Server 7.
I have an object with different data types and one among is date type. I have a stored procedure with all fields as parameters to update a table. The problem is if I don't set any date to my date variable in the object while saving, it is inserting 01/01/1900 as date. I think it is the default date in VB. If I don't set date, I should only insert NULL value to the database. What are the alternatives.
Its weird when I check the following code
Dim tDate as Date
debug.print isNull(tDate) --> this always return false
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Date Conversion As Oracle Database Date Default Format
Select sysdate from dual ; //oracle database
The result is : 28-AUG-04
How to convert “date” in vb to the above format?
Using below statement :
FormatDateTime(Date, vbLongDate) // Saturday, August 28, 2004
Then, combine with string functions (such as instr, left, mid, etc) can be achieved the desired result.
Any shortcut than above mentioned?
SQL Database Date Default
Hi folks! I am just starting to learn SQL server 7.0 and have one question (with probably many to come): how do you set a column's default value to the current date? In Access all i had to do was enter Now() in the default column, but SQL 7.0 doesn't seem to like that...
Validating Server's Date Against A Date In An MS Access Database
I'm trying to redirect a user based on what date the field "expires" in my MS Access 2K DB has - This section is where I want to redirect to a page if the expires date in my database = today.
I'm selecting the table above ( rsUser.Source = "SELECT user_username, user_password, expires" ) but I don't think that the Sub is written right.
currentDate = Date
If expires = Date Then
redirectLoginSuccess = "expiretoday.asp"
I'm new to VB; the ASP page I'm calling this through just skips this routine - which means I didn't do it right. Any suggestions?
VB6 + SQL Server Error: Can't Update. Database Or Object Is Read Only.
I'm hoping someone can help.
I'm using a DAO recordset and SQL Server database (not a great combination).
In any case, on some PCs (not all), sometimes when the AddNew command is run, the application throws the error 'Can't update. Database or object is read only'.
The commands to open the recordset are:
set myrecordset = db.openrecordset(sqlstatement)
myrecordset.lockedits = false
Then the line that fails is:
Does anyone have any ideas what could be causing this?
How To Specify Database Server Or Connection String In A Crystal Report Object
In Visual Basic how can I specify the
database server (or connectionstring)
of a crystal report object at runtime?
I need this because the .exe applications
in terminal computers are trying
to load a crystal report which
database resides in server "(local)"
(obviously because I designed the
report in the server and compiled
the visual basic .exe there too)
Thanks a lot for your help
Default Value For Date
I am uisng VB 6.0. I connecting my VB application to SQL server. The issue I have is the default date i get is
If I dont add any values for the date textbox in VB then in SQL i get the above date. Is there a way I have nothing or null when the date is not added by the user.
Also How can i tell the user to use a particular date format in VB 6.0.
Default Date Value
I have a class that has a date variable as one of its properties
i have a sub in this class called clear which basically clears the contents saved in these variables. so strings are set to "" objects are renewed by reseting them using New and integers/longs are set to 0. What would be the proper way to reinitialize the date? by setting it to "12/30/1899 12:00:00 AM" ?
Retrieve Date From Novell Server (not System Date)
I'm looking for a way to retrieve the date (with or without the time
portion) from our Novell server on the network (rather than the machine's
system date) and store it in a timestamp variable, all from within a VB
program. But, I don't want the system date of the individual machine running
the program to be changed in the process.
Does anyone know if this is possible or even how I would go about doing this
from within my VB program?
Thanks for your help.
Default Db In Sql Server?
i have two db in sql server which a user can access to the two .
FIrst i create a new login with default db1 and i have ticked the two db (include db1) which the user can access under the the tab 'DB Access'.......when i type in the code in vb objConn.Open "DSN=db1"..it works well....
but when i change to objConn.Open "DSN=db2" ...i got the error message : invalid object name xxx.... then i change the default db properties to db2.....and it works when objConn.Open "DSN=db2"...but not when i change to db1....how do i solve this problem so that the change of codes in vb would enabled the access of both db when ever i change the name .. of the two db? thanks
Monthview Default Date.
Hi I am working on the Monthview control. How can I get its upper Caption to always show the current Month and date upon form load. Thanks
Default Date Of Datepicker.
How to set the defaut date shown in date-picker to the current system date? Right now it shows the date on which the control was created..
Using Default Function Date
I want to capture the last two digits of the current year e.g. 2005 would be 05 in my system.
At the moment i've coded this as follows..
variableX = Mid(Date,9,2)
This is because Date (on my system) is returned as dd/mm/yyyy. My question is this... does Date always return in this format? Or is this because of a setting on my system? I don't want to distribute the code then find it's trying to use this code to cut down 1st January 2005 or something in a different format.
The help file doesn't mention return formats.
MySQL Default Date
How do you set a default date field in MySQL.
I have to always specify the date when inserting a new record, when it's not needed.
Your can just use Now() as the default value in Access, what's the default for MySQL?
Is Printer Object The Default
I have code to list each printer in a ComboBox:
Dim i As Integer
For i = 0 To Printers.Count - 1
cboPrinter.AddItem Printers(i).DeviceName, i
After populating the list, I would like the default printer to be selected. Is there a way to either find out in the loop if Printers(i) is the default or find the index of Printer?
Default Object Properties
is there a way to set a textbox, in your control toolbox, to have default properties other than like the current default??ie.white bg, and the style, font etc, for all subsequent objects??
Export Data From SQL Database Server Into Another SQL Database Server
Can somebody help to advise on how to construct for the data transfer for the same type database but different server.
I try to look on how to construct this in the SELECT...INTO statement but I couldn't get what will be the definition on the [Destnation SQL DB table]
SELECT * INTO [Destnation SQL DB table] FROM [Source SQL DB table]
Appreciate if some one have any idea.
Using Default SMTP Server
I've made an app and what i want to do is send an email to myself with some data from the app.
I've got a form where the data is and everything works fine but you have to enter in the smtp server. Is there a way where i can automate this and it sends an email using the clients default SMTP server?
Any help would be greatly appreciated.
Smtp. The Sent Date In Reply Is An Odd Default
The headers are formatted properly. All the info is according to code, except when reply is clicked. The sent date is coming back as
From: Ed Vogel [mailto:firstname.lastname@example.org]
Sent: Friday, July 10, 2893 6:44 PM
To: Ed Vogel
Subject: Information you requested - Diagnostics
Could this be a default setting on our mail sever?
Am I missing a value to be passed to the mailer?
I have hit a wall. Do anyone have an ice pack?
Geting The System Default Date From The API
I need to check that the user of my app has not changed the default date format on their PC. I know you can do this with the API, but can't find out how. Anyone know?
Assign A Default Value To A Date Control
I have a form that adds records to a access table. It contain fields like name, teacher name, exam dates and times. Is there a way to assign a default value to a date or time control? What I want to do is have the ability to leave the field blank if I don't have the date and time when I add the record to table. If I leave it blank I get a type mismatch error. Any suggestions?
Date Problem With Default Behavior
I have a user control and it has some date controls. Once user enters some data, and make a search, this data will be refreshed to the object. From the object I generate find query, execute, load the records and refresh the controls with the data.
I have a small problem with date fields, If don;t select any date, then the date in the object takes the default date "12/30/1899" and executes the query.
How do I work around this problem? thanks
Word Object Default Zoom
I have Word 2000 documents created & formatted in Access 2000 (work was done by a previous developer).
These docs are reports that a couple report preparers in the office use; they eventually go to the clients.
Access closes after the reports are created, but the Word docs are left open at zoom level of 85%. Is there a way to have them default to zoom level of 100%, other than editing the normal.dot template (which would make all new documents open at 100%)? Thanks.
Edited by - salvelinus on 8/12/2004 6:12:24 PM
Problem With Date That Ocassionally Default To 01/01/1901
I have a form that asks the user 'Is this the correct manufacture
date'...this form takes the system date as default but
ocassionally the form has started to display 01/01/1901....
The back end of my app. is an SQL Db
Does anyone have any ideas as to why this may be happening??
Your help is greatly appreciated!!
Default Printer When Word Object Is Open?
I have this code that changes the default printer of the computer to a certain printer. However when i run the programme then it opens an instance of word. The default printer changing has no effect on the ms word object so it seems how can i let the word object also response to my change?
Screen.MousePointer = 11
Dim objPrinter As Printer
Dim tempCount As Long
For Each objPrinter In Printers
If oBtnMenu.Text = objPrinter.DeviceName Then
Dim w As New WshNetwork
Screen.MousePointer = 0
MsgBox oBtnMenu.Text & " is nu de default printer.", vbInformation, "Document Center Online"
Set w = Nothing
'Set VB.defaultprinter = objPrinter
[SQL Server] Alter A Function Which Is Used As A Column Default
I have a function which is used as a default in a number of tables/columns.
I want to alter that function but when I do an "ALTER FUNCTION..." bit of SQL it tells me it can't be altered because it is in use - does anyone have a handy "drop all the defaults, alter function, reinstate all the defaults" type script I could cadge?
I Need A DatePicker Control That Will Handle Nulls And Default Date
I've have a really good look around for a decent DatePicker (about 3 days of testing) but can't seem to locate one which will not only display blanks when null but one which will ALSO default to todays date on drop down.
CCRP does NOT work like I have discribed.
I've already tried the label/textbox over the control but I've just got too many DatePicker controls to have to double up.
Anyone have a control they know will do this?
Create Date/Time Field And Loading Default Value
I am trying to add some fields programmatically to a database using DAO. I need to load some default value to the date/time fields in order that they ar not null. Here is what I tried:
xs = ""
On Error Resume Next
xs = db.TableDefs("Department").Fields("begHH").Name
On Error GoTo 0
If xs <> "reciprocal" Then
db.TableDefs("Department").CreateField("begHH", dbDate / Time)
db.TableDefs("Department").Fields("begHH").DefaultValue = "12:00 AM"
'db.Execute "UPDATE Department SET begHH= "12:00 AM" WHERE
begHH IS NULL", dbFailOnError
It does not like the string of "12:00 AM" at all. Does anyone know what value I should put in the newly created fields. Thanks fo rthe help.
How Can I Get Default Margins Of The Currently Selected Papersize Of The Printer Object ?
"How can I get default margins of the currently selected papersize of the printer object ? "
When we open page-setup in Notepad/Wordpad they always loads with default page of the default printer. And they always load with some pre-defined margins.
No, the margins aren't hard coded. Set the default page of the default printer to a very small one (say 1"x1") from ControlPanel>Printers, and Notepad/Wordpad will reflect the change in margins.
I want to know how they are doing this. Please help me.
Setting Default E-mail Use Of MAPI Server-Urgent
To use the 2 controls Microsoft MAPI Control 6.0 -> MAPISession and MAPIMessages.
I was told that i had to set the default e-mail use of MAPI server. Since i'm a novice, i had problem trying to solve that out.
In my system, i have OutLook Express. What do i have to do to set it as a default e-mail use of MAPI server?
Thanks for your help!
Changing Default Select Part Of Date Time Picker
I have been using VB for many many a year new and I seem to have come across a very strange problem
This is my problem.
I am using a date/time picker on a form. When it first get focus the day figures are highlighted, cursor keys allow the user to go to month and year etc...
Problem it seem to remember the last selected section. So if the user was on the month, the next time they go on the the date/timer picker the month figures are highlighed. I need the date/timer picker to allows be back on the day figure when it get focus...
I hope you understand what I mean
I hope someone can help...
Checking Between Date VB And Date SQL Server
I am trying to check a vb date against a SQL Server 2000 date but it doesn't bring me results.
My DateOfBirth value is "dd-mm-yyyy" and my SQL Server columntype is smalldatetime.
My sub is:
Public Sub checkLeerling()
On Error GoTo Errs
Dim rsLeerling As Recordset
Dim strSQL As String
strSQL = "SELECT Achternaam, Geboortedatum FROM tblLeerling WHERE LOWER(Achternaam) ='" & _
Trim$(LCase(mudtProps.Achternaam)) & "' AND CONVERT(datetime, Geboortedatum , 105)= " & mudtProps.Geboortedatum
Set rsLeerling = New Recordset
rsLeerling.Open strSQL, cnDI, adOpenStatic, adLockReadOnly
If Not (rsLeerling.BOF And rsLeerling.EOF) Then
Set rsLeerling = Nothing
mudtprops.Geboortedatum looks like this:
Public Property Let Geboortedatum(Value As Variant)
If Not mflgEditing Then Err.Raise 383
If Len(Trim(Value)) = 0 Then
mudtProps.Geboortedatum = ""
mobjValid.RuleBroken "Geboortedatum", True
ElseIf IsDate(Value) Then
mudtProps.Geboortedatum = CVDate(Value)
mobjValid.RuleBroken "Geboortedatum", False
mobjValid.RuleBroken "Geboortedatum", True
mflgDirty = True
Public Property Get Geboortedatum() As Variant
Geboortedatum = mudtProps.Geboortedatum
Anybody has an idea why my check on this date doesn't work? Checking purely on the LastName of a student it works perfectly but it needs to check on the date of birth too.....
Need To Create A Connection Object For An Existing Database Object
Below is a fragment where I create a local database and table
which I fill with data from a remote source....
Dim wDef As Workspace
Dim oDB As Database
Dim oTD As TableDef
Dim oRS As ADODB.Recordset
' Get default Workspace.
Set wDef = DBEngine.Workspaces(0)
' Make sure there isn't already a file with the name of
' the new database.
If Dir(cLocalDB) <> "" Then Kill cLocalDB
'create new database
Set oDB = wDef.CreateDatabase(cLocalDB, dbLangGeneral)
'Create a new table
Set oTD = oDB.CreateTableDef("JobMapDraft")
'Create fields and append them to the new TableDef
'object. This must be done before appending the
'TableDef object to the TableDefs collection of the
.Fields.Append .CreateField("DayNo", dbLong)
' Append the new TableDef object to the Northwind
Set oRS = New ADODB.Recordset
query = "insert into JobMapDraft ...............
oRS.Open query, oDB, adOpenDynamic, adLockOptimistic ****
This stalls at **** with a 'Run-time error 3001: Arguments of wrong type....' error
Now, as it happens, I know precisely why this fails - the oRS.Open statement **** needs a Connection object rather than the Database object oDB.
What I would like to know is if there is any way I can create a Connection object from the Database object oDB, or attach a Connection object to it, rather than closing the Databse and using a Connection to it - I would have thought this a sensible facility for MS to include, but you know MS
Time flies like an arrow, Fruit flies like a banana
Need Main() To Create Object, Suspend Until It's Disposed OR Override Default Painthandler
Tried to move this thread to http://www.vbcity.com/forums/topic.asp?tid=43325 but someone decided that wouldn't do, so it's still here. . .
I'm using C#, but since it's so similar to VB.NET, I'll take either format and convert as needed.
I'm making a screensaver that makes matrix-ish code (just hex, and nothing fancy right now) scroll down the screen. This is mostly not important for this thread, but I figured it might help put things into context.
// This is no longer a problem, I discovered that there was some code that got put in weird places... took it out and all is good.
// However, I'd still like to know about making the screen saver without using a form...
Code is all written, except I'm having trouble with /*forms and graphics and */overhead.
/*It displays properly, except that every time I refresh the screen (using an extra paint event), it draws black to the whole form, then does all my custom code next. This creates horrible, horrible flickering. So, I have a couple thoughts on how to fix it:
A: Eliminate the default paint event (I think this is what's redrawing black every time).
B: Don't use a windows form (this /*also*/ has the advantage of getting rid of all the overhead of a form, meaning later I can make more graphics-intensive art).
So, /*if you can answer A, that's great, but*/ I really want answers to B:
I created my own class that inherits nothing (which means it inherits Object...).
The new class will create a drawing surface and draw on it, instead of the form's drawing surface.
So, it will have properties for size, position, refresh rate, etc. and methods for drawing on the graphics object, generating the numbers to draw, etc. Most of this is already done - don't need help here.
What I do need help on is this:
Sub Main() needs to instantiate my class and suspend it's code until the object is destroyed.
Add Click and MouseMove events to my class - I know how to use delegates and add event handlers, et al, but I don't know how to get windows to tell my class that the user moved the mouse or clicked my form without using forms and whatnot that already have them defined. Are events part of the Objects class that get inherited, or maybe part of some other class I haven't found, or do I need to find some way to "hack" into windows and determine such things?
Now, I need to do this stuff too, but I think I have it figured out:
Get the graphics object to actually display on screen - I don't think this has to be a child object to work... should be able to just put it in the right place and start drawing.
Make a timer work - should be able to create a Collection(s) object and put the timer there, or use the System.Timers namespace (I think it exists ).
Right, I think that's it... if you even think you might be able to point me in the right direction, feel free to mislead me. Also, I'm doing this to do it, so I don't need (or really want) source code to do the whole program... just looking for info to get me on the right path.
"It doesn't take a weatherman to know which way the wind blows." Bob Dylan
Edited by - fosley on 10/16/2003 12:50:31 PM
VBA - Can't Assign A Textbox Control To An Object Variable (assumes Default Property)
I'm trying to pass a reference from a control on one form to another form, but it seems that the default property is interfering, and giving me a Type Mismatch error.
Form 1: Single Textbox (Textbox1) and button (mybutton)
In the code, I simply have:
Private myobj As TextBox 'I have tried Control, Object, Variant with the same results
Private Sub UserForm_Initialize()
Set myobj = Me.TextBox1 'I have tried without 'Me', the controls collection, etc.
Private sub mybutton_click()
Set form2.callingfield=myobj 'should set the callingfield = the text box control, but here it gives me an error.
Form 2: No controls, just a Property Set, as a test
Private intcallingfield as TextBox
Public Property Set callingfield (callingfield as TextBox)
The issue is VBA seems to try and pass the TextBox1.Text property (the empty string) rather than the object itself. This code works fine in VB.
How To Set A Default Database
This is my current code for load the database but I want it to look into a recordset before load and see which database I have set for the default. I've been trying to figure that out but having no luck at it.
Public Function dbpath() As Stringdbpath = GetSetting(App.EXEName, "Settings", "Path") If dbpath = "" Then dbpath = App.Path & "Databasemydata.mdb" SaveSetting App.EXEName & Version, "Settings", "Path", dbpath End If End Function
***access To A Server With Pubs SQL Server Sample Database***
I am sort of a newbee in Visual Basic .NET
In order to complete one of the walkthroughs I need
an access to a server with the Pubs SQL Server sample database.
It comes out then, that I should know the name of the server, the password and the likes. Can anybody tell me where could I get 'em?
Couldn't find in Internet any charities with gratis SQL servers databases.
Will the installation of the evaluation option of the SQL Server on my computer serve the purpose? How could I connect to my database from my own pc then?
Can anyone help me, pleeaase?
Thanking you in advance
Set Default For Combo From Database Value
I'm trying to select a default value for a Combo Box (Populated from Backend Database) on Form Load, although the User can modify which item is the default value, so I've got a Default Column in my backend database.
Could anyone point me in the right direction, as to how I should go about this?
Connection To Database Sql Server In Server Failed
i use crystal report 8.5(crviewer to create report) in visual basic 6 and database using sql server . i use ODBC to connect to a database sql server in server and i want to use stored procedure in database sql server to make report.
my problem is connection failed and message box ' connection has not yet been open'.
why? help me
Default Directory In Accessing A Database
Is there a way to force VB to look in the directory where the .exe is located, without specifiying it?
In other words, can I replace the database path with some syntax meaning "look in the current directory," i.e. where the exe is located?
coString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Omni_LogOmni_Log.mdb;Persist Security Info=False;Jet OLEDBatabase Password=****"
coString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<<Current Directory>>Omni_Log.mdb;Persist Security Info=False;Jet OLEDBatabase Password=****"
Kind of Me.show which works for the current form, whatever its name is.
Transferring VB Project From Access Database To SQL Server Database
I have been working on a project at my employer to bring a current program that is run by a third-party company, in-house so that we can run it ourselves instead of paying out monthly fees to the third-party company.
The basics of the program are fairly simple. However, after getting the code about 90-95% done, I am realizing that my Access database will quickly become too small to use. I know we have SQL Server on at least one of our servers, and am thinking about trying to use that instead of Access.
My question is, how hard would it be to transfer my project to a SQL Server database instead of an Access database? I am using ADO to connect to my Access database right now. Would I have to make any adjustments to my VB code? I realize some of the SQL in the code will need to be adjusted, but what about my cn. and rs. lines of code (connections and recordsets)?
Shame on me for not realizing Access's size limitations before now. Any information that anyone can provide is greatly appreciated. Thank you in advance.