2014-04-22 7 views
0

"INSERT INTO Fn_Registration VALUES ('+ txtFirstName.Text +"', "txtLastName.Text +" ', "+"' "+ txtEmailId.Text + "+"txtAddress1.Text + " ',"+ "'"+ "txtAddress2"+ "txtPassword.Text +", "+" 텍스트 + ","+ " '"+ txtFaxNo.Text + "',"+ " '"+ txtFirmName.Text + "',"+ " '"+ txtPhoneNumber.Text + "',"+ " "txtAccountsEnd.Text +" ', + "cbbVat.Text +"', "+" ' "+ cbbstates.Text +"', txtTinNumber.Text + " ' "+" '+ txtCity.Text + "', +"txtBankName.Text + " ',"+ txtAccountNumber.Text + "',"+ " '"+ txtIFSCCode.Text + "',"+ " ' "+"txtBN1.Text + " ',"+ "'+ txtAC1.Text +" ', "+" " '+ txtAC2.Text +"', "+" ' "+ txtIFSC2.Text +"') ";mysql에 자동 증가를 적용 할 수 없습니다.

아이디 NUM은 MySQL의 doesnot 자동 increamented 수 ,,,해야하지만 이곳이 MySQL 데이터베이스로 내 삽입 코드가 자동 점진을 수행하는 하나 개의 도움 .........

C# 코드는 수 당신의 삽입 쿼리에서

string regInset = "INSERT INTO Fn_Registration VALUES ('" + 101 + "', '"+ 
txtFirstName.Text + "', '" + txtLastName.Text + "', " + " '" + txtEmailId.Text + 
"', " + " '" + txtPassword.Text + "', " + " '" + txtPanNumber.Text + "', " + " '" + 
txtAddress1.Text + "', " + " '" + txtAddress2.Text + "', " + " '" + txtFaxNo.Text + 
"'," + " '" + txtFirmName.Text + "', " + " '" + txtPhoneNumber.Text + "', " + " '" 
+ txtTinNumber.Text + "','" + txtAccountsStart.Text + "','" + txtAccountsEnd.Text + 
"','" + cbbVat.Text + "', " + " '" + cbbstates.Text + "', " + " '" + txtCity.Text + 
"', '" + txtBankName.Text + "', '" + txtAccountNumber.Text + "', " + " '" + 
txtIFSCCode.Text + "', " + " '" + txtBN1.Text + "', " + " '" + txtAC1.Text + "', " + 

" '" + txtIFSC1.Text + "', " + " '" + txtBN2.Text + "', " + " '" + txtAC2.Text + "', " 
+ " '" + txtIFSC2.Text + "')"; 

cmd = new MySqlCommand(regInset, con); 
da = new MySqlDataAdapter(cmd); 
ds = new DataSet(); 
da.Fill(ds, "Fn_Registration"); 
this.clearData(); 
+0

후 귀하의'C#을 '코드를! –

+0

쿼리를 작성하고 매개 변수를 직접 전달하지 마십시오. 이는 잘못된 표준 중 하나입니다. 귀하의 질문에 대답하기 위해 ID를 데이터베이스의 ID 열로 언급해야합니다. 여기서는 구성 할 필요가 없습니다. – codebot

+0

어떤 열을 자동 증가시켜야합니까? 101을 넣은 곳? 또는 다른 어떤? 자동 증가로 설정 했습니까? –

답변

1

당신은 사용할 수 있습니다

INSERT INTO Fn_Registration(Names,of,columns,that,you,want,to,give,a,value) VALUES(values,for,those,columns); 

그런 다음 id 컬럼을 값의 컬럼 이름에서 제외하면 SQL은 자동으로 값을 증가시킵니다.

0

MySQL은 다음과 같이 해당 테이블을 수정하여 테이블에 자동 증가로 할 수있다 :

ALTER TABLE tablename MODIFY id_Column INT NOT NULL AUTO_INCREMENT; 

MySQL Documentation

관련 문제