|
Hi,
I am using MySqL-FRONT As my database.I installed MySql beta server,MySQl Font and MySql Odbc driver and I started the service of MySql .But when I am connecting the MySql -Front,the system seems to be hang.The system should have enough space(128 MB RAM).Please help me to overcome this situation.
Jeeva
|
|
|
|
|
thank for your reply(Colin Angus Mackay )in advance!!
----
the type of password field = int
----
and this my code for check!?
----
private void btnOK_Click(object sender, System.EventArgs e)
{
//------->Step :1
if ((txtUserName.Text.Trim().Length == 0)|| (txtPassword.Text.Trim().Length == 0))
{
MessageBox.Show(Empty_MESSAGE,CAPTION_TITLE);
txtPassword.Text="";
txtUserName.Text="";
return;
}
//------>Step :2
string strFilter;
strFilter = "SELECT UserName,Password FROM User_Name WHERE Password='" +txtPassword.Text + "' AND UserName='"+txtUserName.Text+"'";
userAdapter=new SqlDataAdapter(strFilter,UserConnection);
SqlCommandBuilder UserCmd=new SqlCommandBuilder(userAdapter);
DataTable UserTable=new DataTable();
userAdapter.Fill(UserTable);
//------ Counting and Displaying
UserView = new DataView(UserTable,DEFAULT_FILTER,DEFAULT_SORT,DataViewRowState.OriginalRows);
//---->Step :3
if (UserView.Count == 0)
{
MessageBox.Show(NO_RECORDS_FOUND_MESSAGE,CAPTION_TITLE);
txtPassword.Text="";
txtUserName.Text="";
}
else
{
this.Hide();
//----displaying form
Private_Public_Form frm_pub_pri=new Private_Public_Form();
frm_pub_pri.ShowDialog();
}
//************* Finish ********/
}
//-----------
the difficult in this app. is , when password type=int
,system give an error , if we type in textbox of password non-numeral(character)
|
|
|
|
|
First, 15 chars for a password is too small. Normally the passwords I use are 20+ chars and it irritates me when a website cannot accept such a long password. The longer the password, the more secure it is because it takes longer to crack. You should use something like an nvarchar(128) for a password.
Also, you should consider looking at encryption routines so that the password is stored in a secure fashion.
manije wrote:
By the Way if Password type=int [length=4] , what's the result the check ?
That doesn't make any sense.
To check the password on your current set up:
SqlConnection conn = new SqlConnection(myConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT id_user FROM TheUserTable "+
"WHERE username = @username AND password = @password";
cmd.Parameters.Add("@username", myUserName);
cmd.Parameters.Add("@password", myPassword);
conn.Open();
object result = cmd.ExecuteScalar();
if (result == null)
{
}
else
{
int userID = (int)result;
}
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
hi all!
in c#.net:
in my application ,how can it check the user and password
is correct or not ?
for recieve and save user and password , we use a sql Table
thanks in advance!!
mostafa hosseiny b.
|
|
|
|
|
|
hi all
i have made a table in SQL server2000..
now on the button click in my form using vb i want to check weather the value entered in the textbox is available in the column or not...it should check all the values in column of the database.....and display the appropriate msg
please....help me out....i am bugged up by this problem
ashima
ashima
|
|
|
|
|
ashima14 wrote:
i want to check weather the value entered in the textbox is available in the column
There are a number of ways to achieve this, one would be the following SLQ Command
SELECT COUNT(*) FROM TableName WHERE ColumnName = @expectedValue
You can then create an SqlCommand with a parameter called @expectedValue and ExecuteScalar on the SqlCommand . If the result from ExecuteScalar is 0 then you have no match, if the value is anything else then you have a match.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
How i can update my local DataSet when BackEnd Database (SQL Server 2000 etc.) has been changed rapidly by other users. I hate unmanaged code in managed environment. Is there any class like connected recordsets of VB 6.0.
Thanks in advance
Zeeshan
|
|
|
|
|
I am not quite sure I undestand the purpose of your request...
-Is the problem to avoid any users to make changes within your transaction scope..
-Or is the issue to get an over view of other user transactions on the database..
-A hint would be to try execute the folowing stored procedure 'sp_lock'
this will give you all information about existing locks..
|
|
|
|
|
Thanks for reply
I am trying with example.
I have a datagrid shows, currect prices of shares, bound with dataset. I update my local dataset with DB after every 2 second. I think it is a poor design. Because if one row is updated in any 2 second, i update full dataset.
I want, this datagrid shows current share prices, which is updated in DB through my background service without updating the whole dataset.
Zeeshan
|
|
|
|
|
Hi.
I would like connect a database (acess) on web using vb, but I do not know do a connection string.
Do you could help me send me a string or said where I can found it.
Thanks
André
|
|
|
|
|
hi
im a newbe at C# and ado.net,only started three months ago my question is:
i want to add a column at the beginning of a my bound datatable,how do i do that?
code example in c# would be appreciated
thanks for the help
regards paula
|
|
|
|
|
Try YourTable.Columns 's add method where you define a new DataColumn..
But.. this does not guaranty the insert at in the beginneng of the columns, this depends on the existing columns in your table. -To do that
first you have to empty the table for columns YourTable.Clear method will do this, -but before you do this you have to temporarily store any existing columns. then you add your new column and afterwards add the other columns to the table..
Here, code sample for your pupose..
System.Data.DataTable yourTable= new System.Data.DataTable("YourTable");
System.Collections.ArrayList myExistingColumns = new System.Collections.ArrayList();
foreach (System.Data.DataColumn column in yourTable.Columns) //keep any axisting columns..
{
myExistingColumns.Add(column);
}
yourTable.Columns.Clear(); // remove all columns.
yourTable.Columns.Add(new System.Data.DataColumn("MyNewColumn")); //add a new column at the ordinal 0.
foreach (object column in myExistingColumns) //let's movve the existing column back to the table
{
yourTable.Columns.Add((System.Data.DataColumn)column);
}
|
|
|
|
|
Hi guys pls help,I want to add a new column to more than 500 tables in the database,pls help how can I do that.anyone who can provide me with a code??????????
cheerz
|
|
|
|
|
Good luck hehe
You have to automate this somehow.. but don't panic.. I assume it's a SQL-database you are using.
1. you have to traverse all tables for your purpose.. tablenames is stored in the sysobject table.
2. for each table you have to fire ALTER table sql statement.. syntaxt is as following..
sample....
Examples
A. Alter a table to add a new column
This example adds a column that allows null values and has no values provided through a DEFAULT definition. Each row will have a NULL in the new column.
ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL
B. Alter a table to drop a column
This example modifies a table to remove a column.
ALTER TABLE doc_exb DROP COLUMN column_b
C. Alter a table to add a column with a constraint
This example adds a new column with a UNIQUE constraint.
ALTER TABLE doc_exc ADD column_b VARCHAR(20) NULL
CONSTRAINT exb_unique UNIQUE
|
|
|
|
|
Does that mean that I have to fire ALTER table sql statement for each table manually?I actually want to autamate a text file looping through the table names in the sysobject table,also excluding the sys tables when altering,how can I do that?
pls help.
Thanx Guys!!
|
|
|
|
|
Sure you have to fire a Alter table statement...
I could provide you with a code sample... but later on the day if you are patient.
unless..
You have to read all tablenames from the sysobject-table with the xtype of 'U' and furthermore you have to deselect the tablename 'dtproperties' too, I gues the name is. -This will filter all the usertables.
|
|
|
|
|
Sure I am patient.
how can I generate a SQL script Automatically using a code?
something like" Alter Tabe MyTable
ADD Column Null
Default getdate()
pls help???
|
|
|
|
|
Here you go this will do it..
using System;
namespace Tester
{
///
/// Summary description for Class2.
///
public class Class1
{
public Class1()
{
}
public void GenerateColumns(System.Data.SqlClient.SqlConnection connection)
{
string selectstr = "SELECT name FROM sysobjects WHERE xtype ='U' AND name <> 'dtproperties' ORDER BY name";//select only user tables
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(selectstr, connection);
cmd.Connection = connection;
cmd.Connection.Open();
System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
this.AddColumn(dr.GetString(0), cmd.Connection.ConnectionString);
}
cmd.Connection.Close();
}
private void AddColumn(string tableName, string connnectionStr)
{
//ALTER TABLE table ADD column VARCHAR(20) NULL
string alterTableStr = string.Format("ALTER TABLE {0} ADD {1} {2} {3}", tableName, "YourColumnName", "datetime Default getdate()", "NULL");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(alterTableStr, new System.Data.SqlClient.SqlConnection(connnectionStr));
try
{
cmd.Connection.Open();
cmd.ExecuteNonQuery();
}
catch(System.Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
finally
{
cmd.Connection.Close();
}
}
}
}
-- modified at 14:02 Monday 5th September, 2005
|
|
|
|
|
Thanx Guys!!
that code really helped me.
keep on helping the others.
cheerz......
|
|
|
|
|
Hello,
I am developing an application where I need to load custom data to Analysis Server (MS-OLAP) without going through any OLE DB Provider.
I am able to load data into dimensions/cubes using Microsoft OLE DB provider for ODBC Drivers. But my requirement is loading data at runtime from a buffer. Is there any way to do this? Are there any APIs which can help me to load this data directly?
Thanks & regards,
kuldeep kumar
|
|
|
|
|
Hi, Exmaine the following code... specially the first adapter.Fill statement.
DB.DataBase db = new DB.DataBase("NorthWind");
System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter("select * from employees",DB.Global.SqlConnection());
adapter.Fill(db.DataSet); //rows in the 'Employee'-table is empty
adapter.Fill(db.DataSet.Tables["Employees"]]); // this works as expected..
Is there somone that can explane what is the disfference between the 2 lines above.. the Dataset holds all the tables from the northwind Database.
I would as minimum expext, there were some rows in the 'employee'-table.. since I only make a select statement for the 'employee'-table.
|
|
|
|
|
Since a recordset can be obtained from different tables, a SELECT query does not return the name of a table, so the SqlDataAdapter has no way of knowing which table to put the data into. So, it automatically names tables Table , Table1 , Table2 and so on.
After the first Fill call, the DataSet will have a table named Table containing the records retrieved. With the second call, you're telling it which DataTable to fill, so you get what you expect.
The SqlDataAdapter has a property, TableMappings , to solve this issue. Try this code before your Fill call:
adapter.TableMappings.Add("Table", "Employees"); This will tell the data adapter to map the first table returned to the Employees table inside the DataSet .
I hope I've made things clearer!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Thanks a lot, YES now it is very clear
This works!!!
int i = 0;
foreach(DB.DbTable o in db.DataSet.Tables)
{
adapter.TableMappings.Add(string.Format("{0}{1}","Table",i == 0 ? "" : i.ToString()), o.TableName);
adapter.SelectCommand.CommandText += string.Format("SELECT * FROM [{0}]{1} ",o.TableName, i < db.DataSet.Tables.Count ? ";" : "");
i++;
}
adapter.Fill(db.DataSet);
|
|
|
|
|
I'm glad I could help!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|