|
Try the sql authentication method and make sure that the username and the password supplied are correct..
thanks,
SeEa
|
|
|
|
|
Hi, good day.
I have a question about the checkbox in datagrid.
The problem is i have a datagrid in my page and i have 4 checkbox per row in the datagrid. I use the radio button to select the record and i can check the checkbox for certain specify action.
For an example, i select the record to be print in different type of report format. The checkbos is use to select which report format need to be printed out.
Did anyone can help me to solve this problem? Thanks..
-- modified at 22:53 Wednesday 2nd August, 2006
Best Regards,
Pei Sun
|
|
|
|
|
Can anyone tell me what's wrong with this statement (purpose is to update a row if it exists and create it if it doesn't (but that should be obvious)).
IF EXISTS(SELECT * FROM Assemblers WHERE ID = @id)
BEGIN
UPDATE Assemblers SET Name = @name WHERE ID = @id
END
ELSE
BEGIN
INSERT INTO (ID, Name) VALUES (@id, @name)
END
Error is: Incorrect syntax near '('.
Note: I tried writing this on my own, couldn't get it accepted and did a search and someone had posted this code (except for the differing table structures and names) on one of the MSDN forums.
-- modified at 8:39 Wednesday 2nd August, 2006
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
IF EXISTS(SELECT * FROM Assemblers WHERE ID = @id)<br />
<br />
UPDATE Assemblers SET Name = @name WHERE ID = @id<br />
<br />
ELSE<br />
BEGIN<br />
INSERT INTO ????? (ID, Name) VALUES (@id, @name)<br />
END
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Thank you very much for pointing out the obvious, that was a case of staring at the code for much too long
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
Ed.Poore wrote: that was a case of staring at the code for much too long
We all do that!
Kevin
|
|
|
|
|
what is the major and minor differences between SQL2000 and SQL2005
divya
|
|
|
|
|
SQL 2005 has:
* CLR integeation
* Better XML capabilities
* New T-SQL syntax for pivot tables etc.
There are pages and pages on MSDN about this if you need more info.
|
|
|
|
|
Theres is a new Integration Services which replaces DTS.
DTS is "legacy" and can't be changed unless you install a downloadable tool.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
|
It's not very polite to steal someone else's thread.
Please start a new one if you want an answer
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hi,
My is Sql Server2000 dateTime store like this 2006-06-14 12:28:51.983
i m getting this through Store procedure.
i m doing filtering using FromDate to ToDate.
problem is when i m passing same value in FromDate and Todate Like this 2006-06-14 12:28:51 it's not displaying
Help me it's urgent.
-- modified at 6:42 Wednesday 2nd August, 2006
|
|
|
|
|
asif_aslam wrote: My is Sql Server2000 dateTime store like this 2006-06-14 12:28:51.983
Firstly, this is not how SQL Server is storing your date. It is only how it is displaying your date.
asif_aslam wrote: problem is when i m passing same value in FromDate and Todate Like this 2006-06-14 12:28:51 it's not displaying
That is because it is not equal to the date you have in the database. The date you have in the database is 983 milliseconds different to the one you specify.
You may wish to change your ToDate to be one second further on. You may want to use DATEADD(second, 1, @SomeDate) to nudge the ToDate on by one second.
|
|
|
|
|
I have created one new table using datatable.this table does not exist in sql server database.Now when i have created new table,i have created columns and rows and update the values.These values are bound to datagrid and i can see on datagrid.
My question is once i have created this new table,how to update /create this table in sql server.
srkt
|
|
|
|
|
You have to create the table in SQL Server. A DataTable knows nothing of databases, it is disconnected from the database from which its data came (or will be going).
If you are using SQL Server 2000 you can use Enterprise Manager, or you can write some T-SQL to create the table in Query Analyzer. If you are using SQL Server 2005 you can use the SQL Server Management Studio
Once you have the table created in the database you can then use an appropriate DataAdapter (SqlDataAdapter would be best in this case) to transfer information between the DataTable and the actual database.
|
|
|
|
|
hi all i have a sch proj currently that requires me to link up a set of database with a windows form application,that can add,delete, modify the database.. can anyone tell me or show me to some simple articles that does these and provide some sample demo or source codes.. thanks..
|
|
|
|
|
|
Hi, i'm a newby in database in c#.
What I want to do is add a new row to a microsoft access database. I dont use any tables or anything. I just want to get values from labels or whatever and then use that as values for my "Insert into.." query.
I'm using the dataset designer, where I can see my tables and the corresponding tableadapters that were created.
When I test the query on the QUERY CONFIGURATION WIZARD (using fake values), it works fine (i checked de mdb and it added the row with the fake values). What i want to do though is use the same query, but with the corresponding values from my FORM. So it would be like this:
{
INSERT INTO archivo (archivo, [ruta archivo], formato, tamaño, muestreo, bitrate, canales, duracionSeg, [tipo de audio])
VALUES (file, path, format, size, sampling, rate, channels, lenght, audiotype)
}
where (file, path, size, sampling, rate, channels, lenght & audiotype) are my variables that i get from the form. I called the query InsertarAudio, on archivoTableAdapter1.
is there any way i can do this using the wizard and put in the query my external values, so i can then use something like this:
try
{
archivoTableAdapter1.InsertarAudio();
MessageBox.Show("Update successful");
}
catch (System.Exception ex)
{
MessageBox.Show("Update failed");
}
-----------------
I also tried to use:
radioDataSet.AcceptChanges();
try
{
archivoTableAdapter1.InsertarAudio(Archivo, path, auxext, auxsize, auxmuestreo, auxbitrate, auxcanales, auxduracion, cbTipoAudio.Text);
MessageBox.Show("Update successful");
}
catch (System.Exception ex)
{
MessageBox.Show("Update failed");
}
here, where i use directly my variables, i was able to run the project, and the code worked fine (no errors), but it didn't update the mdb.
Thanks to everyone for the time!!!
Hope someone can help me out
daniel sovino
|
|
|
|
|
You will probably need to use an OleDbCommand object.
Set the Command.Text property and other properties and then execute the command.
Something like this:
You need to create your CommandObject and ConnectionObject first...
CommandObject = New OleDbCommand( _
"INSERT INTO archivo (archivo, [ruta archivo], formato, tamaño, muestreo, bitrate, canales, duracionSeg, [tipo de audio]) " & _
"VALUES (" & file &", " & path &", " & format &", " & size &", " & sampling &", " & rate &", " & channels &", " & lenght &", " & audiotype &")", ConnectionObject)
'Open connection
CommandObject.ExecuteNonQuery()
'Close connection
Example is VB.NET but it is similar in C#
Steve
|
|
|
|
|
thanks steve
i tried to use your code, but i keep getting some errors.
"Format of the initialization string does not conform to specification starting at index 92"
on index 92 (line 92??) i have this:
double auxmuestreo = Convert.ToDouble(muestreo);
i think the problem is that im not specifing the type of the variabes. When i made the tables on access, some of the variables are strings, some are doubles
i'm using this.
string source = "Provider=Microsoft.JET.OLEDB.4.0;" + "data source=D:\\tesis\\Importar Archivo\\Importando\\Importando\bin\\radio.mdb";
OleDbCommand comando = new OleDbCommand();
OleDbConnection conexion = new OleDbConnection(source);
string auxsql = "INSERT INTO archivo (archivo, [ruta archivo], formato, tamaño, muestreo, bitrate, canales, duracionSeg, [tipo de audio]) " + "VALUES (" + Archivo + ", " + path + ", desconocido" + tamano.ToString() + ", " + muestreo + ", " + bitrate + ", " + canales + ", " + duracionms + ", " + cbTipoAudio.Text + ")";
comando =new OleDbCommand(auxsql,conexion);
conexion.Open();
comando.ExecuteNonQuery();
conexion.Close();
Once again, thanks a lot. im really stuck on this...
daniel
|
|
|
|
|
kiweed wrote: string source = "Provider=Microsoft.JET.OLEDB.4.0;" + "data source=D:\\tesis\\Importar Archivo\\Importando\\Importando\bin\\radio.mdb";
The above is incorrect. You have the last double quote in the wrong place. Try this:
string source = "Provider=Microsoft.JET.OLEDB.4.0;" + "data source=D:\\tesis\\Importar Archivo\\Importando\\Importando\bin\\radio.mdb;"
Do you need the '\\' double slashes? I don't think so? If not, try this:
string source = "Provider=Microsoft.JET.OLEDB.4.0;" + "data source=D:\tesis\Importar Archivo\Importando\Importando\bin\radio.mdb;"
VS doesn't always give the right index when reporting errors like this. Sometimes it is on the previous or next line...or even on another line!
Steve
|
|
|
|
|
yep, that made it work (the connection)
I still have an error when i use an INSERT on the query.
Just to make sure, i used the OleDbDataReader to make sure i was able to read the database and the connection was working. Everything ok with this:
{
OleDbConnection conexion = new OleDbConnection(source);
OleDbCommand comando = new OleDbCommand();
string auxsql = "SELECT Id, archivo, [ruta archivo], formato, tamaño, muestreo, bitrate, canales,
duracionSeg, [tipo de audio] FROM archivo";
comando =new OleDbCommand(auxsql,conexion);
conexion.Open();
OleDbDataReader reader = comando.ExecuteReader();
while (reader.Read())
{ txtSQL.Text += (reader.GetInt32(0) + ", " + reader.GetString(1)); }
reader.Close();
}
Now, when i use the code down below, i get an OledbException, "No value given for one or more required parameters."
the CommandText is:
INSERT INTO archivo (archivo, [ruta archivo], formato, tamaño, muestreo, bitrate, canales, duracionSeg, [tipo de audio]) VALUES (07-sublime-badfish-chupa.mp3, path , desconocido,4438226, 44100, 187, 2, 184839, Musica)
so i don't get where the error might be at.
{
OleDbConnection conexion = new OleDbConnection(source);
OleDbCommand comando = new OleDbCommand();
string auxsql = "INSERT INTO archivo (archivo, [ruta archivo], formato, tamaño, muestreo, bitrate,
canales, duracionSeg, [tipo de audio]) ";
auxsql += "VALUES (" + Archivo + ", " + "path "+ ", desconocido," + tamano.ToString() + ", " +
muestreo + ", " + auxbitrate + ", " + canales + ", " + duracionms + ", " + cbTipoAudio.Text + ")";
comando =new OleDbCommand(auxsql,conexion);
conexion.Open();
comando.ExecuteNonQuery();
conexion.Close();
}
once again thanks for the help!
daniel
|
|
|
|
|
Hi
I have had this error many times while developing my queries.
It is always caused by not supplying data for one of the 'VALUES' parameters or not defining that parameter correctly...
I notice you are using C#. I use VB.NET but I am familiar with some C#.
While creating a command the way you have, strings must be enclosed by single quotes (''), date values by octothorpes (##).
For example, if tamano.ToString() and cbTipoAudio.Text are string values that you wish to place in a field in your table, you should define them as a 'string within a string' by enclosing them in single quotes:
auxsql += "VALUES (" + Archivo + ", " + "path "+ ", desconocido, '" + tamano.ToString() + "', muestreo + ", " + auxbitrate + ", " + canales + ", " + duracionms + ", '" + cbTipoAudio.Text + "')";
For queries that involve this many parameters, you should look into creating a parameterised query. This would be much easier to construct/read.
Steve
|
|
|
|
|
Ooo yes. Last night while reading i found the answer as well.
I just used 'string' instead of string. Numeric values without any characters. I'll keep in mind the # for date values in the future.
thanks a lot for your help. I was stuck at least 1 week for this, and if it wasn't for your help i'll still be trying to use the dataset designer or whatever....
Here's the working code down below. I think it's the easiest way to add rows to a Access database in C#. No need for components!!
peace!!!!!
--------------------------------------------------------------------------------------
try
{
string source = "Provider=Microsoft.JET.OLEDB.4.0;";
source += "data source=D:\\tesis\\Importar Archivo\\Importando\\Importando\\bin\\radio.mdb;";
OleDbConnection conexion = new OleDbConnection(source);
OleDbCommand comando = new OleDbCommand();
string auxsql = "INSERT INTO archivo (archivo, [ruta archivo], formato, tamaño, muestreo, bitrate,
canales, duracionSeg, [tipo de audio]) ";
auxsql += "VALUES ('" + Archivo + "', '" + path + "', 'desconocido'," + tamano.ToString() + ", " +
muestreo + ", " + auxbitrate + ", " + canales + ", " + duracionms + ", '" + cbTipoAudio.Text +
"')";
comando =new OleDbCommand(auxsql,conexion);
conexion.Open();
comando.ExecuteNonQuery();
conexion.Close();
MessageBox.Show("Update successful");
}
catch (System.Exception ex)
{
MessageBox.Show("Update failed:\r\n"+ex.ToString());
}
daniel kiweed
|
|
|
|
|
Great. Glad I could help!
Steve
|
|
|
|
|