|
Sweet. I havn't had a chance to test it but it looks like it should work. Thanks
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
In the definition of thatTable, you didn't mention whether Field_1 is unique? If it is, then the rest of the table's columns should be added as other columns on ThisTable.
Chris Meech
I am Canadian. [heard in a local bar]
Gently arching his fishing rod back he moves the tip forward in a gentle arch releasing the line.... kersplunk [Doug Goulden]
|
|
|
|
|
hi all this is killing me this statement appears to be correct but not sure
<br />
strSQLUpdate = "UPDATE Software SET ((Name), (Description), (Version), (ProductKey), (Location)) = (['" & n & "'] , ['" & d & "'], ['" & v & "'], ['" & p & "'], ['" & l & "']) WHERE (Name) = {'" & n & "'}"<br />
i have tried with ( ) & with out { } as well
VB6 app to ms access.mdb
please help
thank you
Help is great only if you ask correctly
|
|
|
|
|
Too many brackets for a start. What's going wrong ?
What are you setting Name, Description, Version, etc. to. If nothing, take them out, if something, specify it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Correct me if I'm wrong, but I think the syntax you used is only for INSERT (well, not quite, but similiar), not UPDATE.
Try modifying your statement to:
"UPDATE Software SET Name = '" & n & "', Description = '" & d &"', Version = '" & v & "'" WHERE Name = '" & n & "'
Also, you don't need to set the name when it is used as the condition as the name would have the same value anyway.
Hope it helps
Edbert P.
Sydney, Australia.
|
|
|
|
|
that did it
thank you
the insert statement is like this
<bold>INSERT INTO Software <bold>SET (Name, Description, Version, ProductKey, Location )<bold> Values ( blah blah blah)
Help is great only if you ask correctly
|
|
|
|
|
I recommend using parametized queries. See the documentation for the Parameters property of the OleDbCommand /SqlDbCommand classes.
With parametized queries you avoid problems like invalid characters (a quote for example) or someone trying to hijaack your database by inserting SQL statements.
EDIT: See this[^] post.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi...
I am trying to save data into an excel sheet. The application is working fine here on my local machine (FAT 32). But when I try to run the same application on server (I think NTFS), following error is generated.
What you say? Permission problem or Rights issue?
Please help !!.. .I am stuck ..
Could not find installable ISAM.Microsoft JET Database Engine at
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at
System.Data.OleDb.OleDbConnection.InitializeProvider() at
System.Data.OleDb.OleDbConnection.Open() at PROJ.ClientPaymentData.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\PROJ\ClientPaymentData.aspx.vb:line 67
-------------------
<b>Therez No Place like ... 127.0.0.1</b>
|
|
|
|
|
Hi
Got a Problem with my Data Records. They'll be added double.
By onclick the Add Button the Records are double applied??
What's wrong with my Code?? It's an Access Database.
private void btAdd_Click(object sender, System.EventArgs e)
{
DataAdd();
}
public void DataAdd()
{
OleDbDataAdapter dbAdapter = new OleDbDataAdapter();
conn = new OleDbConnection(ConnectionString);
conn.Open();
string sql ="INSERT INTO tbl_Artikel (Rubrik, Artikel, Regal, Fach, Hersteller, Beschreibung , Preis, Datum, Bestellungsdatum, Lieferungsdatum, Garantie, Seriennr, Mitarbeiter, Verwendung, Lieferant) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
OleDbCommand icmd = new OleDbCommand(sql,conn);
dbAdapter.SelectCommand = icmd;
icmd.Connection=conn;
icmd.Parameters.Add("@Rubrik", OleDbType.VarChar, 50).Value = this.textBoxRubrik.Text;
icmd.Parameters.Add("@Artikel", OleDbType.VarChar, 50).Value =this.textBoxArtikel.Text;
icmd.Parameters.Add("@Regal", OleDbType.VarChar, 50).Value = this.textBoxRegal.Text;
icmd.Parameters.Add("@Fach", OleDbType.VarChar, 50).Value =this.textBoxFach.Text;
icmd.Parameters.Add("@Hersteller", OleDbType.VarChar, 50).Value =this.textBoxHersteller.Text;
icmd.Parameters.Add("@Beschreibung", OleDbType.VarChar, 50).Value =this.textBoxBeschreibung.Text;
icmd.Parameters.Add("@Preis", OleDbType.VarChar, 50).Value =this.textBoxPreis.Text;
icmd.Parameters.Add("@Datum", OleDbType.VarChar, 50).Value =this.textBoxDatum.Text;
icmd.Parameters.Add("@Bestellungsdatum", OleDbType.VarChar, 50).Value =this.textBoxBestellungsdatum.Text;
icmd.Parameters.Add("@Lieferungsdatum", OleDbType.VarChar, 50).Value =this.textBoxLieferungsdatum.Text;
icmd.Parameters.Add("@Garantie", OleDbType.VarChar, 50).Value =this.textBoxGarantie.Text;
icmd.Parameters.Add("@Seriennr", OleDbType.VarChar, 50).Value =this.textBoxSeriennr.Text;
icmd.Parameters.Add("@Mitarbeiter", OleDbType.VarChar, 50).Value =this.textBoxMitarbeiter.Text;
icmd.Parameters.Add("@Verwendung", OleDbType.VarChar, 50).Value =this.textBoxVerwendung.Text;
icmd.Parameters.Add("@Lieferant", OleDbType.VarChar, 50).Value =this.textBoxLieferant.Text;
icmd.ExecuteNonQuery();
DataSet DS = new DataSet();
dbAdapter.Fill(DS, "tbl_Artikel");
conn.Close();
}
|
|
|
|
|
It is because you are calling the INSERT command twice
The first time is here:
icmd.ExecuteNonQuery(); The second time is here:
dbAdapter.Fill(DS, "tbl_Artikel"); The reason it inserts on the Adapter's Fill method is that previously in your code you have set
dbAdapter.SelectCommand = icmd; So, when your adapter attempts to fill a dataset, it actually inserts a row into the database. You should set the SelectCommand property of the DataAdapter to a command that performs a SELECT
Does this help?
Do you want to know more?
WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums
|
|
|
|
|
|
Hi All
im trying to run the below query in Ms-Access
ALTER TABLE cphistory MODIFY unique_number TEXT(50)
which i want to use to chnage the data type of unique_number
but i get a Syntax error
can ne1 help
thanks
si
|
|
|
|
|
|
thanks
si
|
|
|
|
|
Export excel files into sql server using either applications or codings
Eshakarthikeyan
|
|
|
|
|
You can use the DTS wizard that comes with SQL Server to import the data into SQL Server...
Store your favourite bookmarks online: my-faves.co.uk
|
|
|
|
|
Hi
I need some Help. I want to filter Records from one Table.
I got a new Form with two TextBoxes and one DataGrid. The
DataGrid shows the Results after Click on the Button named "Find".
One Textbox is for the DataBase ID. The other TextBox is for common
Text.
Now i need to assign the entered Text from the Textboxes to the sql String.
I hope you know what i mean cause my English is little bit bad sometimes.
I got the following Code and it works.. but how can i assign the text to the
sql Query? So it is static.
private void find ()
{
ds = new DataSet();
string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=...
OleDbConnection conn = new OleDbConnection(ConnectionString);
OleDbCommand cmd = new OleDbCommand("SELECT * FROM tbl_Artikel WHERE ID =88 OR Hersteller LIKE 'Asus' OR Hersteller LIKE ''",conn);
dbAdapter = new OleDbDataAdapter(cmd);
dbAdapter.Fill(ds, "tbl_Artikel");
dataGrid1.DataSource = ds.Tables["tbl_Artikel"].DefaultView;
}
private void btFind_Click(object sender, System.EventArgs e)
{
find();
his.dataGrid1.AlternatingBackColor=Color.Wheat;
}
I tougt something like that, ("SELECT * FROM tbl_Artikel WHERE ID='"+this.textBoxID+"'",conn);
but it don't work furthermore i've heard this is no good solution.
What can I do???
|
|
|
|
|
realmontanakid wrote:
I tougt something like that, ("SELECT * FROM tbl_Artikel WHERE ID='"+this.textBoxID+"'",conn);
but it don't work furthermore i've heard this is no good solution.
That is correct. It is vunerable to SQL Injection Attack. Here is more information about preventing SQL Injection Attacks[^]
What you should do is create parameterised queries.
This means that your command will be something like this:
OleDbCommand cmd = new OleDbCommand("SELECT * FROM tbl_Artikel WHERE ID = ? OR Hersteller LIKE ?",conn);
cmd.Parameters.Add("@id", this.textBoxID.Text);
cmd.Parameters.Add("@hersteller", this.textBoxHersteller.Text);
DISCLAIMER: I am not familiar with exact Access syntax so the above is a guide only. The ideas are correct; the exact implementation may not be correct. For more information on see MSDN: OleDbCommand.Parameters[^]
Do you want to know more?
WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums
|
|
|
|
|
Oracle has got a package called DBMS_SESSION that allows session data to be stored against a connection.
Does SQL Server 2000 have an equivalent feature?
Thanks.
|
|
|
|
|
Hello,everyone
Now i am working with dts,and i want to import data from different catalog to sqlserver,i find it can be implemented through setting globalvariables,and i pass the path to the initial catalog in my program.
Is there anyone who can give me some information on it?Anything will be appreciated .Thanx in advance!
|
|
|
|
|
I have a Dataset with a boolean field that contains a Null value extracted from the db. How can we know it's null ? I convert it to object, and checking against DBNull.Value, and all that stuff, and i can't find a way to do it.
Thanks in advance
Well.. later
|
|
|
|
|
How does Microsoft ObjectSpaces compare to other persistance layer frameworks (like Gentle.NET, iBATIS, nHibernate and so on) ? I been reading blogs and forums for some time and many people feel negative about it, although I suspect it's just because it's from MS.
|
|
|
|
|
I have a static database (well at least for as long as this software runs) and I wondering if any one know if it is better to load all the relevant data into a dataset first and then just work off that the rest of the program or to do many direct hits, returning two or 3 rows at a time, using DataReader?
I’m very new to databases and I’m probably missing some case info that may make a difference. If so, please let me know and I’ll try to be more specific.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
Generally the most efficient in terms of performance is to retrieve only the data that you need.
Whether you use DataSets or DataReaders is more a matter of your programming style, or the nature of the project (small vs large). DataSets are really nice if you are not planning on using business entity objects. If you are planning on using objects, then datareaders are probably a better bet.
If you are new to data access programming, I would say that you should either use DataSets, or use an OR Mapper, such as NHibernate.
my blog
|
|
|
|
|
Hi
I'm from Germany and got a little Problem.
I'm Writing a little Windows Application in C#.
It shows a Datagrid from one Table. Over textboxes
i can add or change Records. Further I can delete
Records. Now the Problem. The Datagrid is in the
first Form. What i need is another Datagrid, in another
Form by clicking on a menuItem. By Click on the MenuItem
the Form is shown but the DataGrid is empty! How can I realize this?
I'm sorry for my fearsome English, but I have no Time;)
FormFilter(MenuItem) is called from the main Function like this:
public FormFilter frm3;
private void miFilter_Click(object sender, System.EventArgs e)
{
frm3=new FormFilter();
frm3.Show();
}
Code FormFilter:
namespace DatabaseAccessWithADONET
{
///
/// Summary description for FormFilter.
///
public class FormFilter : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button btExit;
//DataFilterClass dfc = new DataFilterClass();
//public CurrencyManager currManager;
private DataSet ds;
private System.Windows.Forms.DataGrid dataGrid2;
private OleDbDataAdapter dbAdapter;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public FormFilter()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormFilter));
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btExit = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.dataGrid2 = new System.Windows.Forms.DataGrid();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btExit);
this.groupBox1.Controls.Add(this.textBox2);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(8, 24);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(248, 184);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Filter";
//
// btExit
//
this.btExit.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btExit.Location = new System.Drawing.Point(136, 136);
this.btExit.Name = "btExit";
this.btExit.TabIndex = 4;
this.btExit.Text = "Exit";
this.btExit.Click += new System.EventHandler(this.btExit_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(120, 56);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(120, 20);
this.textBox2.TabIndex = 3;
this.textBox2.Text = "";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(120, 24);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(120, 20);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 56);
this.label2.Name = "label2";
this.label2.TabIndex = 1;
this.label2.Text = "Text";
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 24);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "ID";
//
// dataGrid2
//
this.dataGrid2.CaptionText = "FilterResults";
this.dataGrid2.DataMember = "";
this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid2.Location = new System.Drawing.Point(272, 24);
this.dataGrid2.Name = "dataGrid2";
this.dataGrid2.Size = new System.Drawing.Size(448, 256);
this.dataGrid2.TabIndex = 5;
this.dataGrid2.Click += new System.EventHandler(this.dataGrid2_Click);
//
// FormFilter
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(760, 382);
this.Controls.Add(this.dataGrid2);
this.Controls.Add(this.groupBox1);
this.Name = "FormFilter";
this.Text = "FormFilter";
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
this.ResumeLayout(false);
}
#endregion
public void FormFilter_Load(object sender, System.EventArgs e)
{
ds = new DataSet();
string stConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\Artikel_db.mdb";
OleDbConnection conn = new OleDbConnection(stConnection);
OleDbCommand dbArtikel = new OleDbCommand("select * from tbl_Artikel",conn);
dbAdapter = new OleDbDataAdapter(dbArtikel);
dbAdapter.Fill(ds, "tbl_Artikel");
dataGrid2.DataSource = ds.Tables["tbl_Artikel"].DefaultView;
}
private void btExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
|
|
|
|
|