|
i have a stored procedure named insertreg:
DELIMITER $$DROP PROCEDURE IF EXISTS `naukri4u`.`insertreg`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `insertreg`(emailaddress varchar(50),firstname varchar(50),lastname varchar(50),username varchar(50),password varchar(50),conformpassword varchar(50),mobile varchar(50),currentloc varchar(50),prefferedjobloc varchar(50),gender varchar(50),totalexp varchar(50),industry varchar(50),function varchar(50),keyskills varchar(50),highestqual varchar(50),yearofpass varchar(50),institute varchar(50),resumetitle varchar(50),resume varchar(50))
BEGIN
insert into registration(emailaddress,firstname,lastname,username,password,conformpassword,mobile,currentloc,prefferedjobloc,gender,totalexp,industry,function,keyskills,highestqual,yearofpass,institute,resumetitle,resume)
values(emailaddress,firstname,lastname,username,password,conformpassword,mobile,currentloc,prefferedjobloc,gender,totalexp,industry,function,keyskills,highestqual,yearofpass,institute,resumetitle,resume);
END$$DELIMITER ;
i want to submit a regisration form using this stored proc.this registration table have primary key reg_id which auto increments so
i have not taken it in my query.the code i have written is:
public DataSet insert(Common.com_registration objcom_reg)
{
registration reg = new registration();
try
{
DbParameter dbparama0 = DAC.Parameter("emailaddress", objcom_reg.Emailaddress, DbType.String, ParameterDirection.Input);
DbParameter dbparama1 = DAC.Parameter("firstname", objcom_reg.Firstname, DbType.String, ParameterDirection.Input);
DbParameter dbparama2 = DAC.Parameter("lastname", objcom_reg.Lastname, DbType.String, ParameterDirection.Input);
DbParameter dbparama3 = DAC.Parameter("username", objcom_reg.Username, DbType.String, ParameterDirection.Input);
DbParameter dbparama4 = DAC.Parameter("password", objcom_reg.Password, DbType.String, ParameterDirection.Input);
DbParameter dbparama5 = DAC.Parameter("conformpassword", objcom_reg.Conformpassword, DbType.String, ParameterDirection.Input);
DbParameter dbparama6 = DAC.Parameter("mobile", objcom_reg.Mobile, DbType.String, ParameterDirection.Input);
DbParameter dbparama7 = DAC.Parameter("currentloc", objcom_reg.Currentlocation, DbType.String, ParameterDirection.Input);
DbParameter dbparama8 = DAC.Parameter("prefferedjobloc", objcom_reg.Prefferedjobloc, DbType.String, ParameterDirection.Input);
DbParameter dbparama9 = DAC.Parameter("gender", objcom_reg.Gender, DbType.String, ParameterDirection.Input);
DbParameter dbparama10 = DAC.Parameter("totalexp", objcom_reg.Totalexp, DbType.String, ParameterDirection.Input);
DbParameter dbparama11= DAC.Parameter("industry", objcom_reg.Industry, DbType.String, ParameterDirection.Input);
DbParameter dbparama12= DAC.Parameter("function", objcom_reg.Function, DbType.String, ParameterDirection.Input);
DbParameter dbparama13= DAC.Parameter("keyskills", objcom_reg.Keyskills, DbType.String, ParameterDirection.Input);
DbParameter dbparama14= DAC.Parameter("highestqual", objcom_reg.Highestqual, DbType.String, ParameterDirection.Input);
DbParameter dbparama15= DAC.Parameter("yearofpass", objcom_reg.Yearofpassing, DbType.String, ParameterDirection.Input);
DbParameter dbparama16= DAC.Parameter("institute", objcom_reg.Institute, DbType.String, ParameterDirection.Input);
DbParameter dbparama17= DAC.Parameter("resumetitle", objcom_reg.Resumetitle, DbType.String, ParameterDirection.Input);
DbParameter dbparama18= DAC.Parameter("resume", objcom_reg.Resume, DbType.String, ParameterDirection.Input);
DbParameter[] dbparamcoll = new DbParameter[] {dbparama0,dbparama1,dbparama2,dbparama3,dbparama4,dbparama5,dbparama6,dbparama7,dbparama8,dbparama9,dbparama10,dbparama11,
dbparama12,dbparama13,dbparama14,dbparama15,dbparama16,dbparama17,dbparama18};
DbParameter dbParam0 = DAC.Parameter("v_userid", objcom_reg.Emailaddress, DbType.String, ParameterDirection.Input);
DbParameter dbParam1 = DAC.Parameter("v_headline", objcom_reg.Emailaddress, DbType.String, ParameterDirection.Input);
DbParameter[] dbParamColl = new DbParameter[] { dbParam0, dbParam1 };
return DAC.SelectDS("insertreg", dbparamcoll);
}
catch(Exception exp)
{
throw exp;
}
i am passing a object which is initialized with all the values from my registration form.i am calling this insert function
at my registratin form.hope now u r clear with my prob.
modified on Monday, November 29, 2010 6:59 AM
|
|
|
|
|
Put a break point in the code and check each objcom_reg. value, see if a string value is not initialised and is therefore null.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i have chechked several time sthe code is correct.evwerythinworks finebut the error comes
at line:
return DAC.SelectDS("insertreg", dbparamcoll);
afterb this line the control skip to exception block.
|
|
|
|
|
and what are dbparama2,dbparama3,dbparama4,dbparama5,dbparama6,dbparama7,dbparama8,dbparama9,dbparama10,dbparama11,dbparama12,dbparama13,dbparama14,dbparama15,dbparama16,dbparama17,dbparama18?
|
|
|
|
|
Hasn't really worked out the array thingy yet!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
<edit>You are setting dbparamcoll twice but with different parameters. The first setting is never used.</edit>
Ok, it's official, I'm blind like a bat.
"When did ignorance become a point of view" - Dilbert
modified on Monday, November 29, 2010 11:18 AM
|
|
|
|
|
actually there are two arrays with different casing, and it is the second one that isn't used.
|
|
|
|
|
Crap, That's a sign that I need to go home now.
"When did ignorance become a point of view" - Dilbert
|
|
|
|
|
I suspect your insertreg procedure is not providing a value for a key column.
|
|
|
|
|
Experts,
In my oracle database i have a column "Description". I have to show only 25 characters while writing the select command. Is there any way for that or i have to use cursor
|
|
|
|
|
|
hello
TSQL to print the content/inside of stored proc, definition of view and tables?
The idea is to automate detection of any changes to stored proc or view/table schema.
Thanks
dev
|
|
|
|
|
Uhm it's called source control and there are a vast number of systems built to meet this need. And they almost all cost money.
Otherwise you can look into the system tables and possibly the schema views, all the procedure scripts are in there. You can write then out or copy them to another table where you could simply do a != comparison on the relevant fields.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You may use
1. information_schema.columns for columns
2. information_schema.tables for tables
3. sp_helptext 'sp_procedurename' for SP Text
|
|
|
|
|
I have a primary key in StudentTable in mySQL database called (schoolDB)... I was using it for testing and now i want to rest the primary key to start from 1
how can I do that?
|
|
|
|
|
Try this :
ALTER TABLE yourTable AUTO_INCREMENT=1
Be sure to delete all rows first.
Cheers
I don't like my signature at all
|
|
|
|
|
|
You're oversimplifying things a bit in my opinion.
It does need to be unique, and it does not matter what the values actually are if you are using surrogate keys.
But there is such a thing as natural keys, and there's nothing wrong in using them if it fits the model.
Here[^] is yet another article on the subject by Joe Celko.
"When did ignorance become a point of view" - Dilbert
|
|
|
|
|
Jörgen Andersson wrote: You're oversimplifying things a bit in my opinion
I'm sure I was.
Thanks for the link, I'll read the article.
|
|
|
|
|
Use
DBCC CHECKIDENT('Customer', RESEED, 0) for Resetting Identity seed.
Regards,
Hiren.
"We owe a lot to the Indians, who taught us how to count, without which no worthwhile scientific discovery could have been made." - Einstein
Microsoft Dynamics CRM
|
|
|
|
|
In SQL Server 2005...
How to get Column Value From a Statement if Table Name passes dynamically through a variable....?
|
|
|
|
|
You need to use dynamic sql in your prodecure.
Declare @SQL varchar(100)
set @SQL = 'Select ' + @Field + ',' + @Field2 +' from TableName'
Exec (@SQL)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Declare one more variable and assign first column value and Print this value.......
Okay..........
|
|
|
|
|
But why use a stored procedure at all? Just do the same thing but in regular code.
|
|
|
|
|
Hi I am using a SQL statement to access data from a database, if I hardcode a specific name in the field I get, the name being searched for is returned and displayed. Of-course this isn't a convient way of doing things so I introduced a text box to take in the data, store it in a variable then, this is were my problem lies, I try and used my variable in the SQL statement but it does not work. My code is as below:
<br />
static private string GetConnectionString()<br />
{<br />
<br />
return<br />
"Driver={Microsoft Access Driver (*.mdb)};"<br />
+ "Dbq=c:\\Users\\Tichaona\\Documents\\My Dropbox\\SET10101 Software Architecture\\coursework1\\patients.mdb;Uid=java;Pwd=password;";<br />
}<br />
<br />
private void BtnSearch_Click(object sender, EventArgs e)<br />
{<br />
String nameSearch = TxtBxName.Text; <<<The variable I wish to use<br />
try<br />
{ <br />
<br />
string connectionString = GetConnectionString();<br />
string queryString = "SELECT Name FROM patients WHERE Name LIKE '%nameSearch%';"; <<<Here<br />
using (OdbcConnection connection =<br />
new OdbcConnection(connectionString))<br />
{<br />
OdbcCommand command = connection.CreateCommand();<br />
command.CommandText = queryString;<br />
<br />
<br />
try<br />
{<br />
connection.Open();<br />
<br />
OdbcDataReader reader = command.ExecuteReader();<br />
<br />
<br />
<br />
while (reader.Read())<br />
{<br />
<br />
LstBxResults.Items.Add(reader.GetString(0));<br />
<br />
<br />
}<br />
<br />
reader.Close();<br />
}<br />
<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
<br />
<br />
}<br />
}<br />
}
catch (Exception er)<br />
{<br />
MessageBox.Show("There is an error {0}" + er);<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
}<br />
}<br />
<br />
<br />
|
|
|
|
|