Binding the date field to textbox
Hi,
I have the problem with binding the textbox with date field in the table of
the dataset.
The problem is that if the entered text in the textbox isn't of the correct
type (for example "dfhd" instead of "12.6.2003"), the text gets
automatically overwritten by the old value. That way the user has to type
everything all over again instead of just correcting the entered value.
Is there a way to prevent old value to overwrite the entered text?
I used the following code to bind the textbox to a dataview...
Dim objBinding As New Binding("Text", ds.NETBill.DefaultView, "Date")
AddHandler objBinding.Format, AddressOf FormatDate
txtDatum.DataBindings.Add(objBinding)
...and following code to validate entered text...
Private Sub txtDatum_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles txtDatum.Validating
If Not ControlValue.CheckValue (txtDate, ControlValue.ETip.tDate,
ds.NETRacun.DefaultView(0)) Then
e.Cancel = True
End If
End Sub
Regards,
Taras Tag: FW: Use that important update Tag: 67166
ADO OR ADO.NET
I am using VS.NET to develop one small software which based on Windowsforms.
The number of end user is less than 10. So I am wondering I should use ADO
or ADO.NET. Any suggestion is appreciated. Tag: FW: Use that important update Tag: 67153
Record locking Strategies? (ADO.NET)
Due to the disconnected architecture of the ADO.NET model
which are the recomended strategies for application which
requires record locking (for example a Online Ticket
Application)?
Thanks
Bill Tag: FW: Use that important update Tag: 67152
OracleClient special characters in column name
Hello
I am working with System.Data.OracleClient
How can I create a table with special characters in
column name ?
I have tried:
OracleCommand oCmd = new OracleCommand("CREATE TABLE
T1 ('_C1' number)");
oCmd.ExecuteNonQuery();
OracleCommand oCmd = new OracleCommand("CREATE TABLE
T1 (\"_C1\" number)");
oCmd.ExecuteNonQuery();
OracleCommand oCmd = new OracleCommand("CREATE TABLE
T1 (\\_C1 number)");
oCmd.ExecuteNonQuery();
OracleCommand oCmd = new OracleCommand("CREATE TABLE
T1 ({_}C1 number)");
oCmd.ExecuteNonQuery();
... but it does not work.
Thanks for replies. Tag: FW: Use that important update Tag: 67151
Connection pooling in Oracle
Hi,
How can I implement connection pooling in Oracle? I used .NET Framework 1.0,
Oracle .NET Provider 1.0 and Oracle Database 9i
Thanks for the help...
Eka Tag: FW: Use that important update Tag: 67149
Oracle .NET Provider 1.1
Hi all,
Where can I download Oracle .NET Provider 1.1? Is it available at all?
I need this because i got this error: "Failed to initialize distributed
transaction. Please see KB article Q322343."
I saw the KB already and it said that i need to download Oracle .NET
Provider 1.1 but I couldn't find it.
Thanks for help..
Eka Tag: FW: Use that important update Tag: 67148
Problem with the OleDb.OleDbCommandBuilder
Hi all,
Since my experience with sql is just beginning to grow
i use the commandbuilder object to generate updatecommands deletecommands
insertcommands.
With first run th update works without a problem
when i call my update function again (changing the same row again) i get
"Concurrency violation: the UpdateCommand affected 0 records."
Exception
The debugger shows that the dataset.datatable.row.rowstate = modified
But the update simply doesn't work
Does anyone know what i am doing wrong ?
any help would be greatly appreciated
Thanks & regards
Sven
Code:
For i = 0 to ds.tables.count -1
da.SelectCommand = New OleDb.OleDbCommand("SELECT * FROM " &
ds.Tables(i).TableName, mConnection)
comm = New OleDb.OleDbCommandBuilder(da)
da.UpdateCommand = comm.GetUpdateCommand
da.DeleteCommand = comm.GetDeleteCommand
da.InsertCommand = comm.GetInsertCommand
rowsaffected = da.Update(ds.Tables(i))
Debug.WriteLine("Updated table: " & ds.Tables(i).TableName & " affected
rows: " & rowsaffected)
Next Tag: FW: Use that important update Tag: 67144
Controls missing in the forms
Hi All,
I am developing an ERP Application in VB.Net. I have used a common
dataset and all the form level datasets are used the common dataset for the
"datasetname"property. But when I open the form, its dead slow to show the
design of the form. My system is P4, 256 MB RAM.
May I know the soluation for the same or welcome any suggestions?.
Also sometimes the control are missing while loading the form in the
design time. but the same control object is available in the genereated code
of the form.
Can u help me for the same??
Thanks,
Rethish Tag: FW: Use that important update Tag: 67141
Reading Excel with ADO
Hello,
I have tried to read Excel spreadsheet through ADO. I used the sample code
provided by msdn.I don't know what the fuck is the matter with the code
cause I can't read the Excel. I tried similar system with Access and it
works fine. Here is the error and the sample code.
Error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'
[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not
find the object 'ASPTOC'. Make sure the object exists and that you spell its
name and the path name correctly.
/ASPTOC.asp, line 21
Code:
<%@Language=VBScript %>
<html>
<head>
<title> Displaying An Excel Spreadsheet in an Web Page </title>
</head>
<body bgcolor="#FFFFFF" text="#000000" >
<h1>ASP Table of Contents</h1>
<%
'Creates an instance of an Active Server Component
Set oConn = Server.CreateObject("ADODB.Connection")
'Connects to the Excel driver and the Excel spreadsheet
'in the directory where the spreadsheet was saved
strProvider = "Driver={Microsoft Excel Driver (*.xls)};
DBQ=C:\Inetpub\wwwroot\Testi_site\ASPTOC.xls;"
'Opens the connection to the data store
oConn.Open strProvider
'Selects the records from the Excel spreadsheet
strCmd = "SELECT * from `ASPTOC`"
Set oRS = Server.CreateObject("ADODB.Recordset")
'Opens the recordset
oRS.Open strCmd, oConn
'Prints the cells and rows in the table
Response.Write "<table border=1><tr><td>"
'Gets records in spreadsheet as a string and prints them in the table
Response.Write oRS.GetString (, , "</tr><td>", "</td></tr><tr><td>",
NBSPACE)
%>
</body>
</html>
It looks like ODBC error but I did the ODBC like instructed. I also
installed the .net framework and latest MDAC to the server. The sample code
instructions say that u should use Excel 98 or 2000. I'm using Excel 2002.
Can this be the problem?? I think i've tried everything but can't figure
this out. Can anyone please help me???
Thanks!
KS Tag: FW: Use that important update Tag: 67138
Confused by one more piece of IBindingList
Thanks for all the help I've been getting working on understanding
IBindingList and data binding in general.
My understanding about IBindingList is that it's primary use is for binding
custom strongly typed collections to complex controls (primarily DataGrid)..
So by grouping the parts of the interface into their various functionality
I'm coming to grips with how it works, with one exception..
Datagrid doesn't have any searching ability AFAIK, so why does IBindingList
have functionality for searches? I know that it's optional, and doesn't
have to be implemented.. But every other piece of the interface maps to a
piece of the puzzle needed for the grid to be able to handle adding,
removing, editing rows of data, sorting them, and so on.
So is the search functionality actually used? And if so where?
I hope I'm not just being obtuse.. I'm just trying to make sure I don't
dismiss that section of the interface and then later find out it's used
internally by something else, and I've hosed things by not implementing it..
Thanks in advance (again)
William Rowland Tag: FW: Use that important update Tag: 67133
How do I format datagrid column to short time?
In my VB.Net program I am populatating a datagrid column using an MS Access
database field that that contains data formated in "Short Time" (17:34).
Right now, the datagrid displays the entire date and time. I need only the
short time. How can I do this simply?
I dont't use ASP.
Thanks,
Gigi Tag: FW: Use that important update Tag: 67128
Looking for dialog to browse available connections
Can anyone point me to a dialog box which will allow me to browse for an
ADO.NET (or ODBC) connection?
The user would select the provider (ODBC data source), the server, database
etc. Dialog would construct the connection string.
Thanks Tag: FW: Use that important update Tag: 67127
Binding a SQL Image Column to an Image Control - Can I Avoid Saving The ByteStream/FileStream To Disk ?
This is a multi-part message in MIME format.
------=_NextPart_000_001E_01C385E1.A67BC190
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I have a C#/ASP.NET/ADO.NET/SQL Server app that stores and retrieves =
images.=20
The problem is the ASP Image control binds to a file. When retrieving an =
image from SQL, I would really like to avoid saving the =
ByteStream/FileStream to disk, just to then read it back into the Image =
control.=20
Is there a way to avoid this?
// This is my current implentation. It works, but requires lots of disk =
i/o.
// Write the ByteArray to a FileStream and then the FileStream to disk.
iLen =3D mySqlDataReader.GetBytes(0, 0, myByteArray, 0, lBufSize);
FileStream myFS =3D new FileStream(@"c:\image.jpg", FileMode.Create, =
FileAccess.Write);
myFS.Write(myByteArray, 0, iLen);
ASPImage1.ImageUrl =3D @"c:\image.jpg";
Thanks in advance,
Ben
------=_NextPart_000_001E_01C385E1.A67BC190
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3D"Courier New" size=3D2>I have a C#/ASP.NET/ADO.NET/SQL =
Server app=20
that stores and retrieves images. </FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>The problem is the ASP Image =
control binds=20
to a file. When retrieving an image from SQL, I would really like =
to avoid=20
saving the ByteStream/FileStream to disk, just to then read it back =
into=20
the Image control. <BR></FONT><FONT><FONT face=3D"Courier New" =
size=3D2>Is there a=20
way to avoid this?</FONT></DIV></FONT>
<DIV><FONT size=3D2><FONT face=3D"Courier New"><FONT><FONT=20
face=3DArial></FONT> </DIV></FONT></FONT></FONT>
<DIV><FONT face=3D"Courier New" size=3D2>// This is my current=20
implentation. It works, but requires lots of disk=20
i/o.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>// Write the ByteArray to a =
FileStream and=20
then the FileStream to disk.<BR>iLen =3D mySqlDataReader.GetBytes(0, 0,=20
myByteArray, 0, lBufSize);<BR>FileStream myFS =3D new =
FileStream(@"c:\image.jpg",=20
FileMode.Create, FileAccess.Write);<BR>myFS.Write(myByteArray, 0,=20
iLen);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>ASPImage1.ImageUrl =3D=20
@"c:\image.jpg";</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Ben</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_001E_01C385E1.A67BC190-- Tag: FW: Use that important update Tag: 67122
Cursors and ExecuteNonQuery
All,
Is it possible for ExecuteNonQuery to open a cursor? The
reason I ask is that I'm debugging a client's C# service
which is leaking cursors and eventually Oracle throws a
MAX CURSOR EXCEEDED exception and the service dies a
horrible death. It appears that the method that is the
main culprit calls several stored procedures which do
something like:
INSERT INTO FOO ( ... ) RETURNING FOO_ID;
The FOO_ID is setup in the C# as an output parameter and
additionally, the client never calls the Dispose method on
the Command object.
Additionally, the Command objects are used like so:
cmd = new OleDbCommand("sp1", cnx);
...
cmd.ExecuteNonQuery();
...
cmd = new OleDbCommand("sp2", cnx);
...
cmd.ExecuteNonQuery();
...
Would this technique cause cursor leaks? Thanks...
Matt Tag: FW: Use that important update Tag: 67121
Not getting SqlException using DataReader
I'm using a SqlDataReader to call a proc that reads data. My call to
raiseerror has no effect. Below is the code. if i comment out the select
statement, my code behaves as expected.
CREATE PROCEDURE [dbo].[usp_Table1Read]
@id int
AS
--select * from table1 where IId = @Id
if (@@rowcount = 0)
begin
raiserror('an error occured', 10, 1)
return 50000
end
return 0
GO
using System;
using System.Data;
using System.Data.SqlClient;
namespace ReaderTest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Class1 c = new Class1();
c.DoWork();
}
public void DoWork()
{
try
{
//connection
SqlConnection connection = new SqlConnection();
connection.ConnectionString = "Persist Security Info=False;Integrated
Security=SSPI;database=MyDataBase;server=(local)";
connection.Open();
connection.InfoMessage += new
SqlInfoMessageEventHandler(this.MySqlInfoHandler);
//command
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "usp_Table1Read";
command.Connection = connection;
//create return parameter
SqlParameter p = new SqlParameter();
p.ParameterName = "@RetVal";
p.Direction = ParameterDirection.ReturnValue;
p.SqlDbType = SqlDbType.Int;
command.Parameters.Add(p);
p = new SqlParameter();
p.ParameterName = "@Id";
p.Direction = ParameterDirection.Input;
p.SqlDbType = SqlDbType.Int;
p.Value = "3";
command.Parameters.Add(p);
//get reader
SqlDataReader reader = command.ExecuteReader();
//look at return parameter (1)
Console.Write("Check 1: ");
Console.WriteLine(command.Parameters["@RetVal"].Value);
while(reader.Read()){}
reader.Close();
connection.Close();
//look at return parameter (2)
Console.Write("Check 2: ");
Console.WriteLine(command.Parameters["@RetVal"].Value);
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
public void MySqlInfoHandler(object sender, SqlInfoMessageEventArgs e)
{
Console.WriteLine("************************");
Console.WriteLine(e.Message);
Console.WriteLine("************************");
}
}
} Tag: FW: Use that important update Tag: 67120
Referencing datarow/datareader values by property name vs index - How big a hit?
I've read several times that there is a performance hit when referencing
column values in ADO.Net by property name vs index number. Could someone
clue me in to how serious a hit this is, and maybe point me towards an
explanation as to the extra steps involved in referencing by name that are
causing the slowdown?
i.e.
variable=datareader(3)
is faster than
variable=datareader("LastName")
I hate giving up readability in my code (my code documentation skills are
bad enough already), and I've also got a paranoia of the order of columns
somehow getting shifted around. (I know when I bind a table to a datagrid,
the column order doesn't always match the order in the table..)
Any comments?
Thanks,
W.G. Rowland Tag: FW: Use that important update Tag: 67116
Cannot find rows with GUID
Hello All
I have a table with column ID that is a uniqueidentifier. However I
can't seem to use the Find method of the Rows to located a GUID row.
For e.g. I'm passing a GUID string as
"{2446AF50-386F-4EC6-9E3D-44C4F1ACBF70}" and then using this to locate
the row
//Initialization ....
oDAProjectData.Fill(oDS);
DataTable tbl = oDS.Tables["PData"];
tbl.PrimaryKey = new DataColumn[]{tbl.Columns["ID"]};
// In update method...somewhere in code
DataRow dr = oDS.Tables["PData"].Rows.Find(new Guid(projID));
However, dr is evaluating to null so I can't update the row. Any ideas
what might be wrong here.
thanks
Sunit Tag: FW: Use that important update Tag: 67103
clear a value from combo
i can do a clear and i clear all the items of my combo but the selected
value stay
how could i remove it. i've tried to remove each item but i have a problem
of data type between integer and string Tag: FW: Use that important update Tag: 67102
read a combo binded by code
i can bind a combo by coding with somethin' like that:
Me.ComboBox1.DataSource = dataset
Me.ComboBox1.DisplayMember = "tabla.Descripcion"
Me.ComboBox1.ValueMember = "tabla.idPublicoObjetivo"
but i can't read it:
i think it should somethin' like:
Me.Label1.Text = Me.ComboBox1.SelectedText.ToString
Me.Label2.Text = Me.ComboBox1.SelectedValue
but it doesnt work. Tag: FW: Use that important update Tag: 67088
Visual Studio generated Update Queries.. Is this the way to go?
I'm fairly new to SQL Server, and I've been using Visual Studio to help
generate some SQLCommands to make life easier. The Insert, Delete, and
Select Commands it produces all seem fairly straightforward, but I'm
wondering about the Update Commands it generates.
Basically what it seems to do is generate an Update command with parameters
for each property, and then a second parameter for each property in the
Where clause.. So to update a record, it would expect you to enter every
column value of the record to be updated, and then all the new values as
well..
In my case I will always be using the unique identity column to select which
record I'm going to update, and I'm wondering if there's any reason (such as
some effeciency issue in SQL I don't know about) to requre my code to supply
every property in the where clause, or if I could just trim all the extra
parameters and have it simply update record WHERE ID=@parameterID..?
Thanks in advance,
William Rowland Tag: FW: Use that important update Tag: 67081
Looking for good reference on the data binding interfaces, especially IBindingList
Does anybody know of any good books or sites that cover the data binding
interfaces? I'm trying to put together a set of business collections to
handle my data, and though I can find articles that cover parts of the
interfaces, I've yet to find any detailed explanation on all of
IBindingList.. (i.e. That covers sorting and searching, and the rest..)
Any suggestions would be highly appreciated, as I'm feeling as if I'm in way
over my head..
William Rowland Tag: FW: Use that important update Tag: 67080
bind a combo by coding
how can i bind by coding with valueMember, displayMember and datasource
properties.
if i do it visually, that's right but if i code it, not.
i do somethin' like that:
Dim gCadenaConexion As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source= " & ObtenRutaAplicacion() & "Datos\Datos.mdb"
Dim conexion As New OleDb.OleDbConnection(gCadenaConexion)
Dim adapter As New OleDb.OleDbDataAdapter("SELECT idPublicoObjetivo,
Descripcion FROM PublicoObjetivo", conexion)
Dim dataset As New DataSet()
conexion.Open()
adapter.Fill(dataset, "tabla")
conexion.Close()
Me.ComboBox1.DataSource = dataset
Me.ComboBox1.DisplayMember = "Descripcion"
Me.ComboBox1.ValueMember = "idPublicoObjetivo" Tag: FW: Use that important update Tag: 67078
Re-Arrange columns in datagrid?
Ended up using the following to hide unwanted columns and set the width of a
column. Now I want to re-arrange the displayed order of the columns, so I
tried creating another table style and adding the columns in the order I
wanted them, but for some reason I end up with all table style settings
gone. Anyone see what I'm doing wrong?
Thanks - Sean
'Hide un-wanted column
Me.DsGameInfo.Tables("Games").Columns("Home").ColumnMapping =
MappingType.Hidden
'Set column widths
Dim dgts As New DataGridTableStyle()
dgts.MappingName = "Games"
Me.dgGames.TableStyles.Add(dgts)
dgts.GridColumnStyles("Game").Width = 150
'Re-arrange colums
Dim dgts2 As New DataGridTableStyle()
dgts2.GridColumnStyles.Add(dgts.GridColumnStyles("Game"))
dgts2.GridColumnStyles.Add(dgts.GridColumnStyles("Home Score"))
dgts2.GridColumnStyles.Add(dgts.GridColumnStyles("Guest Score"))
dgts2.GridColumnStyles.Add(dgts.GridColumnStyles("Week / Year"))
Me.dgGames.TableStyles.Remove(dgts)
Me.dgGames.TableStyles.Add(dgts2)
Me.dgGames.Refresh() Tag: FW: Use that important update Tag: 67071
Changing the code generated by the strongly typed dataset designer
In the light of my previous message, is it possible to change the code
generated by the designer used for DataSet's?
I would like to be able to change the visibility of some properties and
methods to protected instead of private (I know I can use 'new' but ...) and
I would also like to move some of the class hierarchy around.
Cheers. Tag: FW: Use that important update Tag: 67067
Use of DataRowBuilder class
I have recently been doing a lot of work using Strongly Typed DataSet's and
have a (simple?) question.
The classes generated by the designer use the System.Data.DataRowBuilder
class in the constructor of the xxxRow classes. This class is documented
within the Framework help files as being used to support the framework only.
This has previously been stated to mean that the class is subject to removal
or change at a later date if MS so desire, but doing this will then mean
that any code based upon STDS's will cease to function.
Comments? Tag: FW: Use that important update Tag: 67066
Queries problem
Hi
I have two queries as sql strings. How can I take the results of two queries
and use them in a third sql query?
Thanks
Regards Tag: FW: Use that important update Tag: 67056
Connection timeout problem
I have a problem with the connection timeout property .It
dosn't work properly . I have changed its value but
the "Timeout expired" error appears. Tag: FW: Use that important update Tag: 67050
SELECT records with field employee # in a series of #
What is the SQL string to select records with CODE, for example, in a
series of CODES.
SELECT * from employees for code in "2345,4566,5678,7777"
That's the idea, to select employees whose code is one in the series of
the string.
There has to be an easier equivalent to..
SELECT * from employees for code=2345 or code=4566 or...
because the numbercuase.
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! Tag: FW: Use that important update Tag: 67049
UPDATE command is driving me crazy
I can delete and add but why is this so hard?
Please tell me what I am doing wrong.........
Dim sConn1 As New OleDb.OleDbConnection
sConn1.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet
OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Jet OLEDB:Database Password=;Data Source=" &
databasepath & _
";Password=;Jet OLEDB:Engine T" & _
"ype=5;Jet OLEDB:Global Bulk
Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Je" & _
"t OLEDB:System database=;Jet OLEDB:SFP=False;Extended
Properties=;Mode=Share Den" & _
"y None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
Database=False;J" & _
"et OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact
Without Replica Re" & _
"pair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False"
If TextBox1.Text = "" Or ComboBox1.Text = "" Or TextBox2.Text = ""
Then
MsgBox("All required fields do not have entries.",
MsgBoxStyle.Critical, "Neumann Plumbing and Heating Software")
Exit Sub
End If
Dslogin1.Clear()
Dslogin1.AcceptChanges()
sql2 = "select AlphaPagerNumber, EmployeeID, EmployeeName,
FaxNumber, [Group], LoggedIn, NumericPagerNumber, [Password] FROM cbEmployee
where employeename = '" & TextBox1.Text & "'"
OleDbDataAdapter1 = New OleDb.OleDbDataAdapter(sql2, sConn1)
OleDbDataAdapter1.Fill(Dslogin1.cbEmployee)
Dslogin1.AcceptChanges()
Dim itemcheck As Integer
Dim foundit As Boolean
For itemcheck = 0 To Dslogin1.Tables("cbEmployee").Rows.Count - 1
If TextBox1.Text =
Dslogin1.Tables("cbEmployee").Rows(itemcheck).Item("EMPLOYEENAME") Then
foundit = False
Exit For
End If
If TextBox1.Text <>
Dslogin1.Tables("cbEmployee").Rows(itemcheck).Item("EMPLOYEENAME") Then
foundit = True
End If
'Exit Sub
Next
If foundit = False Then
With Dslogin1.Tables("cbEmployee")
' Modify the first record (just append 3 asterisks to Name
field)
.Rows(0)("Employeeid") = .Rows(0)("Employeeid").ToString
.Rows(0)("EmployeeName") = TextBox1.Text.ToString
.Rows(0)("AlphaPagerNumber") = 0
If TextBox3.Text = "" Then
.Rows(0)("FaxNumber") = 0
Else
.Rows(0)("FaxNumber") = TextBox3.Text.ToString
End If
.Rows(0)("Group") = ComboBox1.Text.ToString
If TextBox5.Text = "" Then
.Rows(0)("NumericPagerNumber") = 0
Else
.Rows(0)("NumericPagerNumber") = TextBox5.Text.ToString
End If
.Rows(0)("Password") = TextBox2.Text
.Rows(0).AcceptChanges()
End With
Dslogin1.AcceptChanges()
CreateUpdateCommand()
Dslogin1.AcceptChanges()
OleDbDataAdapter1.Update(Dslogin1.cbEmployee)
OleDbDataAdapter1.AcceptChangesDuringFill = True
MsgBox(TextBox1.Text & " has had their record modified.",
MsgBoxStyle.Information, "Neumann Plumbing and Heating Software - User
Modified")
closeme = True
'Me.Hide()
Exit Sub
End If
If foundit = True Then
'rowdeletion = True
MsgBox("This user does not exist in the database.",
MsgBoxStyle.Critical, "Neumann Plumbing and Heating Software - User Does Not
Exist")
Exit Sub
End If
End Sub
Private Function CreateUpdateCommand() As OleDbCommand
Dim sConn45 As New OleDb.OleDbConnection
sConn45.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet
OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Jet OLEDB:Database Password=;Data Source=" &
databasepath & _
";Password=;Jet OLEDB:Engine T" & _
"ype=5;Jet OLEDB:Global Bulk
Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Je" & _
"t OLEDB:System database=;Jet OLEDB:SFP=False;Extended
Properties=;Mode=Share Den" & _
"y None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
Database=False;J" & _
"et OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact
Without Replica Re" & _
"pair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False"
Dim strsql As String
strsql = "UPDATE cbEmployee SET AlphaPagerNumber = ?, EmployeeName =
?, FaxNumber = ?, [Gro" & _
"up] = ?, LoggedIn = ?, NumericPagerNumber = ?, [Password] = ? WHERE
(EmployeeN" & _
"ame = '" & TextBox1.Text & "') "
Dim cmd As New OleDbCommand(strsql, sConn45)
Dim pc As OleDbParameterCollection = cmd.Parameters
pc.Add("AlphaPagerNumber", System.Data.OleDb.OleDbType.VarWChar, 14,
"AlphaPagerNumber")
pc.Add("EmployeeName", System.Data.OleDb.OleDbType.VarWChar, 20,
"EmployeeName")
pc.Add("FaxNumber", System.Data.OleDb.OleDbType.VarWChar, 14,
"FaxNumber")
pc.Add("Group", System.Data.OleDb.OleDbType.VarWChar, 15, "Group")
'Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("LoggedIn",
System.Data.OleDb.OleDbType.Boolean, 2, "LoggedIn"))
pc.Add("NumericPagerNumber", System.Data.OleDb.OleDbType.VarWChar,
14, "NumericPagerNumber")
pc.Add("Password", System.Data.OleDb.OleDbType.VarWChar, 10,
"Password")
'pc.Add("Original_EmployeeName",
System.Data.OleDb.OleDbType.VarWChar, 20,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"EmployeeName", System.Data.DataRowVersion.Original, Nothing))
pc.Add("Original_EmployeeName",
System.Data.OleDb.OleDbType.VarWChar, 20, "EmployeeName")
pc.Add("Original_AlphaPagerNumber",
System.Data.OleDb.OleDbType.VarWChar, 14, "AlphaPagerNumber")
pc.Add("Original_AlphaPagerNumber1",
System.Data.OleDb.OleDbType.VarWChar, 14, "AlphaPagerNumber")
pc.Add("Original_FaxNumber", System.Data.OleDb.OleDbType.VarWChar,
14, "FaxNumber")
pc.Add("Original_FaxNumber1", System.Data.OleDb.OleDbType.VarWChar,
14, "FaxNumber")
pc.Add("Original_Group", System.Data.OleDb.OleDbType.VarWChar, 15,
"Group")
pc.Add("Original_Group1", System.Data.OleDb.OleDbType.VarWChar, 15,
"Group")
'Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_LoggedIn",
System.Data.OleDb.OleDbType.Boolean, 2,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"LoggedIn", System.Data.DataRowVersion.Original, Nothing))
pc.Add("Original_NumericPagerNumber",
System.Data.OleDb.OleDbType.VarWChar, 14, "NumericPagerNumber")
pc.Add("Original_NumericPagerNumber1",
System.Data.OleDb.OleDbType.VarWChar, 14, "NumericPagerNumber")
pc.Add("Original_Password", System.Data.OleDb.OleDbType.VarWChar,
10, "Password")
pc.Add("Original_Password1", System.Data.OleDb.OleDbType.VarWChar,
10, "Password")
'cmd.Transaction.Commit()
Return cmd
End Function Tag: FW: Use that important update Tag: 67044